home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume4 / dragon / patch1 < prev    next >
Encoding:
Internet Message Format  |  1989-05-23  |  68.9 KB

  1. Path: uunet!island!argv
  2. From: argv@island.uu.net (Dan Heller)
  3. Newsgroups: comp.sources.x
  4. Subject: v04i005:  Dragon, Patch1
  5. Message-ID: <766@island.uu.net>
  6. Date: 24 May 89 07:37:07 GMT
  7. Organization: Island Graphics, Marin County, California
  8. Lines: 2391
  9. Approved: island!argv@sun.com
  10.  
  11. Submitted-by: Gary Barnes <uunet!igor!amber!geb>
  12. Posting-number: Volume 4, Issue 5
  13. Archive-name: dragon/patch1
  14.  
  15. [ Gary originally sent me the entire source all over again.  I just extracted
  16.   it and diff'ed it against what I originally posted.  The result is a
  17.   couple of new files (board.c is broken into a new board.c and draw.c as
  18.   well as Makefile.Canned) and the next posting contains diffs against the
  19.   last posted version.  None of the icon files have changed.  Make sure to
  20.   read the README once you've applied the patches.  --argv ]
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then feed it
  24. # into a shell via "sh file" or similar.  To overwrite existing files,
  25. # type "sh file -c".
  26. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  27. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  28. # If this archive is complete, you will see the following message at the end:
  29. #        "End of shell archive."
  30. # Contents:  board.c draw.c Makefile.Canned
  31. # Wrapped by argv@island on Wed May 24 00:18:35 1989
  32. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  33. if test -f 'board.c' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'board.c'\"
  35. else
  36. echo shar: Extracting \"'board.c'\" \(27424 characters\)
  37. sed "s/^X//" >'board.c' <<'END_OF_FILE'
  38. X/******************************************************************************
  39. X* Dragon - a version of Mah-Jongg for X Windows
  40. X*
  41. X* Author: Gary E. Barnes    March 1989
  42. X*
  43. X* board.c - Deals with the Mah-Jongg board.  Setup and execution.
  44. X******************************************************************************/
  45. X
  46. X#define _BOARD_C_
  47. X
  48. X#include "main.h"
  49. X#include "board.h"
  50. X
  51. Xextern long random();
  52. X
  53. X
  54. Xvoid Write_Game( file )
  55. X     FILE    *file;
  56. X/******************************************************************************
  57. X*   file    - Specifies a file open for write
  58. X*
  59. X* Called to write out the current game context for later rereading.
  60. X******************************************************************************/
  61. X{
  62. X
  63. X    (void)fwrite( (char*)&Score, 1, sizeof(Score), file );
  64. X    (void)fwrite( (char*)&Board_Tiles[0][0], 1, sizeof(Board_Tiles), file );
  65. X
  66. X} /* Write_Game */
  67. X
  68. X
  69. Xvoid Read_Game( file )
  70. X     FILE    *file;
  71. X/******************************************************************************
  72. X*   file    - Specifies a file open for reading
  73. X*
  74. X* Called to read in a new current game context.
  75. X******************************************************************************/
  76. X{
  77. X
  78. X    Click1 = Board_Position_NULL;
  79. X    Click2 = Board_Position_NULL;
  80. X    (void)fread( (char*)&Score, 1, sizeof(Score), file );
  81. X    (void)fread( (char*)&Board_Tiles[0][0], 1, sizeof(Board_Tiles), file );
  82. X
  83. X} /* Read_Game */
  84. X
  85. X
  86. Xstatic int Pick_Tile( Avail )
  87. X     char    *Avail;
  88. X/******************************************************************************
  89. X*   Avail    - Specifies an [NTILES] array of available tiles.  Unavailable
  90. X*          slots contain NO_TILE.
  91. X*
  92. X* Called to pick a random tile from the Available tiles.
  93. X******************************************************************************/
  94. X{
  95. X    register char    *t;
  96. X    register int    k;
  97. X
  98. X/*--Pick a random starting place. */
  99. X
  100. X    k = (int)random() % NTILES;
  101. X    t = &Avail[k];
  102. X
  103. X/*--Search until we find a non-NO_TILE slot. */
  104. X
  105. X    while (*t == NO_TILE) {
  106. X    ++t;
  107. X    if (++k == NTILES) {
  108. X        t = &Avail[0];
  109. X        k = 0;
  110. X    }
  111. X    }
  112. X
  113. X/*--Return the tile we found and zap the slot. */
  114. X
  115. X    k = *t;
  116. X    *t = NO_TILE;
  117. X    return k;
  118. X
  119. X} /* Pick_Tile */
  120. X
  121. X
  122. Xvoid Set_Tile_Controls()
  123. X/******************************************************************************
  124. X* Called whenever the board has been reset or resized.  We recalculate all of
  125. X* the drawing controls for the tiles.
  126. X******************************************************************************/
  127. X{
  128. X    register Board_Position    bp;
  129. X    int                row, col;
  130. X
  131. X/*--Now set up the control information for all of the tiles.  The special
  132. X *  tiles are easy. */
  133. X
  134. X    DEBUG_CALL(Set_Tile_Controls);
  135. X    if (Board_Tiles[SPEC4].level > 0) {
  136. X    Board_Tiles[SPEC4].x         = Board_Tile0_X + 6 * (Tile_Width + 1)
  137. X                        + (Tile_Width + 1) / 2 + 4 * Side_X;
  138. X    Board_Tiles[SPEC4].y         = Board_Tile0_Y + 3 * (Tile_Height + 1)
  139. X                      + (Tile_Height + 1) / 2 - 3 * Side_Y;
  140. X    }
  141. X
  142. X    if (Board_Tiles[SPEC3].level > 0) {
  143. X    Board_Tiles[SPEC3].x         = Board_Tile0_X + 0 * (Tile_Width + 1);
  144. X    Board_Tiles[SPEC3].y         = Board_Tile0_Y + 3 * (Tile_Height + 1)
  145. X                      + (Tile_Height + 1) / 2;
  146. X    }
  147. X
  148. X    if (Board_Tiles[SPEC2].level > 0) {
  149. X    Board_Tiles[SPEC2].x         = Board_Tile0_X + 13 * (Tile_Width+1);
  150. X    Board_Tiles[SPEC2].y         = Board_Tile0_Y +  3 * (Tile_Height+1)
  151. X                      + (Tile_Height + 1) / 2;
  152. X    }
  153. X
  154. X    if (Board_Tiles[SPEC1].level > 0) {
  155. X    Board_Tiles[SPEC1].x         = Board_Tile0_X + 14 * (Tile_Width+1);
  156. X    Board_Tiles[SPEC1].y         = Board_Tile0_Y +  3 * (Tile_Height+1)
  157. X                            + (Tile_Height + 1) / 2;
  158. X    }
  159. X
  160. X/*--Do the more regular tiles. */
  161. X
  162. X    for (row = 0; row <= 7; ++row) {
  163. X    for (col = 12; col >= 1; --col) {
  164. X        bp = &Board_Tiles[row][col];
  165. X
  166. X/*--Skip any tiles that don't exist. */
  167. X
  168. X        if (bp->level == 0) { continue; }
  169. X
  170. X/*--Set up the face x/y coordinates. */
  171. X
  172. X        bp->x = Board_Tile0_X + col * (Tile_Width + 1);
  173. X        bp->y = Board_Tile0_Y + row * (Tile_Height + 1);
  174. X
  175. X    }
  176. X    }
  177. X    DEBUG_RETURN(Set_Tile_Controls);
  178. X
  179. X} /* Set_Tile_Controls */
  180. X
  181. X
  182. Xstatic void Pick1( bp, Avail )
  183. X     register Board_Position     bp;
  184. X     char            *Avail;
  185. X{
  186. X    bp->tiles[0] = Pick_Tile( Avail );
  187. X    bp->level = 1;
  188. X}
  189. X
  190. Xstatic void Pick2( bp, Avail )
  191. X     register Board_Position     bp;
  192. X     char            *Avail;
  193. X{
  194. X    bp->tiles[0] = Pick_Tile( Avail );
  195. X    bp->tiles[1] = Pick_Tile( Avail );
  196. X    bp->level = 2;
  197. X}
  198. X
  199. Xstatic void Pick3( bp, Avail )
  200. X     register Board_Position     bp;
  201. X     char            *Avail;
  202. X{
  203. X    bp->tiles[0] = Pick_Tile( Avail );
  204. X    bp->tiles[1] = Pick_Tile( Avail );
  205. X    bp->tiles[2] = Pick_Tile( Avail );
  206. X    bp->level = 3;
  207. X}
  208. X
  209. Xstatic void Pick4( bp, Avail )
  210. X     register Board_Position     bp;
  211. X     char            *Avail;
  212. X{
  213. X    bp->tiles[0] = Pick_Tile( Avail );
  214. X    bp->tiles[1] = Pick_Tile( Avail );
  215. X    bp->tiles[2] = Pick_Tile( Avail );
  216. X    bp->tiles[3] = Pick_Tile( Avail );
  217. X    bp->level = 4;
  218. X}
  219. X
  220. X
  221. Xvoid Setup_New_Game()
  222. X/******************************************************************************
  223. X* Called to generate an all-new game.
  224. X******************************************************************************/
  225. X{
  226. X    register Board_Position    bp;
  227. X    char            Avail[NTILES];
  228. X    int                row, col, i;
  229. X
  230. X/*--Clear the board. */
  231. X
  232. X    DEBUG_CALL(Setup_New_Game);
  233. X    bp = &Board_Tiles[0][0];
  234. X    for (row = 0; row < NROWS; ++row) {
  235. X    for (col = 0; col < NCOLS; ++col) {
  236. X        bp->tiles[0] = NO_TILE;
  237. X        bp->tiles[1] = NO_TILE;
  238. X        bp->tiles[2] = NO_TILE;
  239. X        bp->tiles[3] = NO_TILE;
  240. X        bp->level = 0;
  241. X    }
  242. X    }
  243. X
  244. X/*--Mark all tiles as available. */
  245. X
  246. X    i = 0;
  247. X    for (row = 0; row < 4; ++row) {
  248. X    Avail[i++] = row + 1;
  249. X    Avail[i++] = row + 5;
  250. X    for (col = 8; col < NFACES; ++col) {
  251. X        Avail[i++] = 1 + col % NFACES;
  252. X    }
  253. X    }
  254. X    if (i != NTILES) { (void)fprintf( stderr, "NTILES gak!\n" ); }
  255. X
  256. X/*--Fill in the "odd" tile slots. */
  257. X
  258. X    Pick1( &Board_Tiles[SPEC1], Avail );
  259. X    Pick1( &Board_Tiles[SPEC2], Avail );
  260. X    Pick1( &Board_Tiles[SPEC3], Avail );
  261. X    Pick1( &Board_Tiles[SPEC4], Avail );
  262. X
  263. X    for (col = 1; col <= 12; ++col) {
  264. X    Pick1( &Board_Tiles[0][col], Avail );
  265. X    Pick1( &Board_Tiles[7][col], Avail );
  266. X    }
  267. X    for (row = 1; row <= 6; ++row) {
  268. X    Pick1( &Board_Tiles[row][ 3], Avail );
  269. X    Pick1( &Board_Tiles[row][10], Avail );
  270. X    }
  271. X    for (row = 2; row <= 5; ++row) {
  272. X    Pick1( &Board_Tiles[row][ 2], Avail );
  273. X    Pick1( &Board_Tiles[row][11], Avail );
  274. X    }
  275. X    for (row = 3; row <= 4; ++row) {
  276. X    Pick1( &Board_Tiles[row][ 1], Avail );
  277. X    Pick1( &Board_Tiles[row][12], Avail );
  278. X    }
  279. X
  280. X/*--Now do the next square at level 2. */
  281. X
  282. X    for (col = 4; col <= 9; ++col) {
  283. X    Pick2( &Board_Tiles[1][col], Avail );
  284. X    Pick2( &Board_Tiles[6][col], Avail );
  285. X    }
  286. X    for (row = 2; row <= 5; ++row) {
  287. X    Pick2( &Board_Tiles[row][4], Avail );
  288. X    Pick2( &Board_Tiles[row][9], Avail );
  289. X    }
  290. X
  291. X/*--Now do the next square at level 3. */
  292. X
  293. X    for (col = 5; col <= 8; ++col) {
  294. X    Pick3( &Board_Tiles[2][col], Avail );
  295. X    Pick3( &Board_Tiles[5][col], Avail );
  296. X    }
  297. X    for (row = 3; row <= 4; ++row) {
  298. X    Pick3( &Board_Tiles[row][5], Avail );
  299. X    Pick3( &Board_Tiles[row][8], Avail );
  300. X    }
  301. X
  302. X/*--Now do the final square at level 4. */
  303. X
  304. X    for (row = 3; row <= 4; ++row) {
  305. X    for (col = 6; col <= 7; ++col) {
  306. X        Pick4( &Board_Tiles[row][col], Avail );
  307. X    }
  308. X    }
  309. X
  310. X/*--Now set up the control information for all of the tiles. */
  311. X
  312. X    Set_Tile_Controls();
  313. X    Score = NTILES;
  314. X    DEBUG_RETURN(Setup_New_Game);
  315. X
  316. X} /* Setup_New_Game */
  317. X
  318. X
  319. X/*ARGSUSED*/
  320. Xvoid Restart_Game( w, event, params, num_params )
  321. X     Widget    w;
  322. X     XEvent    *event;
  323. X     String    *params;
  324. X     Cardinal    *num_params;
  325. X/******************************************************************************
  326. X* Called when the RESTART button is pressed.  Restart the game.
  327. X******************************************************************************/
  328. X{
  329. X    int                row;
  330. X    int                col;
  331. X    register Board_Position    bp;
  332. X
  333. X/*--Reset levels and remove hilites. */
  334. X
  335. X    DEBUG_CALL(Restart_Game);
  336. X    Click1 = Board_Position_NULL;
  337. X    Click2 = Board_Position_NULL;
  338. X    Score = NTILES;
  339. X    bp = &Board_Tiles[0][0];
  340. X    for (row = 0; row < NROWS; ++row) {
  341. X    for (col = 0; col < NCOLS; ++bp,++col) {
  342. X        if      (bp->tiles[3] != NO_TILE) { bp->level = 4; }
  343. X        else if (bp->tiles[2] != NO_TILE) { bp->level = 3; }
  344. X        else if (bp->tiles[1] != NO_TILE) { bp->level = 2; }
  345. X        else if (bp->tiles[0] != NO_TILE) { bp->level = 1; }
  346. X        else { bp->level = 0; }
  347. X    }
  348. X    }
  349. X
  350. X/*--Finish setting up and then redraw everything. */
  351. X
  352. X    Set_Tile_Controls();
  353. X    XClearArea( XtDisplay(Board), XtWindow(Board), 0, 0, 0, 0, TRUE );
  354. X    DEBUG_RETURN(Restart_Game);
  355. X
  356. X} /* Restart_Game */
  357. X
  358. X
  359. Xstatic void Set_Tile_Draw( row, col )
  360. X     int    row;
  361. X     int    col;
  362. X/******************************************************************************
  363. X*   row    - Specifies the row of the tile
  364. X*   col - Specifies the column of the tile
  365. X*
  366. X* Called to set the "draw" flag on a tile.  We also recursively set the
  367. X* draw flag on anyone that needs to be redrawn because we are being redrawn.
  368. X******************************************************************************/
  369. X{
  370. X    register Board_Position    bp = &Board_Tiles[row][col];
  371. X
  372. X/*--If we don't exist or if we are already being redrawn then stop. */
  373. X
  374. X    DEBUG_CALL(Set_Tile_Draw);
  375. X    if (bp->level == 0 || bp->draw) {
  376. X    return;
  377. X    }
  378. X
  379. X/*--Redraw us.  Redraw anyone to our left that has a height greater than ours
  380. X *  because their shadow/tile-face overlaps us. */
  381. X
  382. X    bp->draw = TRUE;
  383. X    if (col > 0 &&
  384. X    Board_Tiles[row][col-1].level > bp->level) {
  385. X    Set_Tile_Draw( row, col-1 );
  386. X    }
  387. X
  388. X/*--Redraw anyone below us that has a level greater than ours because their
  389. X *  shadow/tile-face overlaps us. */
  390. X
  391. X    if (row < 7 &&
  392. X    Board_Tiles[row+1][col].level > bp->level) {
  393. X    Set_Tile_Draw( row+1, col );
  394. X    }
  395. X
  396. X/*--Redraw anyone below-to-the-left of us. */
  397. X
  398. X    if (row < 7 &&
  399. X    col > 0 &&
  400. X    Board_Tiles[row+1][col-1].level > 0) {
  401. X    Set_Tile_Draw( row+1, col-1 );
  402. X    }
  403. X
  404. X/*--Redraw anyone above-to-the-left of us that has a level greater than ours
  405. X *  because their tile-face overlaps our tile-edge. */
  406. X
  407. X    if (row > 0 && col > 0 &&
  408. X    Board_Tiles[row-1][col-1].level != bp->level) {
  409. X    Set_Tile_Draw( row-1, col-1 );
  410. X    }
  411. X
  412. X/*--If we are certain specific tiles then we may need to set specific other
  413. X *  tiles. */
  414. X
  415. X    if (row == 3 || row == 4) {
  416. X    if (col == 6 || col == 7) {
  417. X        Set_Tile_Draw( SPEC4row, SPEC4col );
  418. X    } else if (col == 1) {
  419. X        Set_Tile_Draw( SPEC3row, SPEC3col );
  420. X    }
  421. X    }
  422. X    DEBUG_RETURN(Set_Tile_Draw);
  423. X
  424. X} /* Set_Tile_Draw */
  425. X
  426. X
  427. Xstatic void Remove_Tile( bp, row, col )
  428. X     register Board_Position    bp;
  429. X     int            row;
  430. X     int            col;
  431. X/******************************************************************************
  432. X* Called to remove the top tile of the indicated Board_Position.
  433. X******************************************************************************/
  434. X{
  435. X
  436. X/*--If the tile just went away then clear the area and allow the window
  437. X *  background to shine through. */
  438. X
  439. X    DEBUG_CALL(Remove_Tiles);
  440. X    if (bp->level == 1) {
  441. X    if (Tile_Control & SHADOW) {
  442. X        XClearArea( XtDisplay(Board), XtWindow(Board),
  443. X                bp->x, bp->y - Side_Y - Shadow_Y,
  444. X                Tile_Width + Side_X + 2 + Shadow_X,
  445. X                Tile_Height + Side_Y + 2 + Shadow_Y,
  446. X                FALSE );
  447. X    } else {
  448. X        XClearArea( XtDisplay(Board), XtWindow(Board),
  449. X                bp->x, bp->y - Side_Y,
  450. X                Tile_Width + Side_X + 2,
  451. X                Tile_Height + Side_Y + 2,
  452. X                FALSE );
  453. X    }
  454. X    } else {
  455. X    int    sidex = Side_X * bp->level;
  456. X    int    sidey = Side_Y * bp->level;
  457. X    if (Tile_Control & SHADOW) {
  458. X        XClearArea( XtDisplay(Board), XtWindow(Board),
  459. X                bp->x + sidex, bp->y - sidey - Shadow_Y,
  460. X                Tile_Width + 2 + Shadow_X,
  461. X                Tile_Height+ 2 + Shadow_Y,
  462. X                FALSE );
  463. X    } else {
  464. X        XClearArea( XtDisplay(Board), XtWindow(Board),
  465. X                bp->x + sidex, bp->y - sidey,
  466. X                Tile_Width + 2,
  467. X                Tile_Height+ 2,
  468. X                FALSE );
  469. X    }
  470. X    Set_Tile_Draw( row, col );
  471. X    }
  472. X    --bp->level;
  473. X
  474. X/*--Schedule the surrounding tiles for redrawing. */
  475. X
  476. X    if (col == SPEC1col) {
  477. X    if (row == SPEC4row) {
  478. X        Set_Tile_Draw( 3, 6 );
  479. X        Set_Tile_Draw( 3, 7 );
  480. X        Set_Tile_Draw( 4, 6 );
  481. X        Set_Tile_Draw( 4, 7 );
  482. X        return;
  483. X    } else if (row == SPEC3row) {
  484. X        Set_Tile_Draw( 3, 1 );
  485. X        Set_Tile_Draw( 4, 1 );
  486. X        return;
  487. X    } else if (row == SPEC2row) {
  488. X        Set_Tile_Draw( SPEC1row, SPEC1col );
  489. X        Set_Tile_Draw( 3, 12 );
  490. X        Set_Tile_Draw( 4, 12 );
  491. X        return;
  492. X    } else {
  493. X        Set_Tile_Draw( SPEC2row, SPEC2col );
  494. X        Set_Tile_Draw( 3, 12 );
  495. X        Set_Tile_Draw( 4, 12 );
  496. X        return;
  497. X    }
  498. X    }
  499. X    if (col == 1 && (row == 3 || row == 4)) {
  500. X    Set_Tile_Draw( SPEC3row, SPEC3col );
  501. X    }
  502. X    if (col == 12 && (row == 3 || row == 4)) {
  503. X    Set_Tile_Draw( SPEC2row, SPEC2col );
  504. X    }
  505. X    if (row > 0) {
  506. X    Set_Tile_Draw( row - 1, col + 1 );
  507. X    Set_Tile_Draw( row - 1, col     );
  508. X    if (col > 0 &&
  509. X        Board_Tiles[row-1][col].level == 0) {
  510. X        Set_Tile_Draw( row - 1, col - 1 );
  511. X    }
  512. X    }
  513. X    Set_Tile_Draw( row, col+1 );
  514. X    if (col > 0) {
  515. X    Set_Tile_Draw( row,     col - 1 );
  516. X    }
  517. X    if (row < 7) {
  518. X    Set_Tile_Draw( row + 1, col     );
  519. X    if (col > 0) {
  520. X        Set_Tile_Draw( row + 1, col - 1 );
  521. X    }
  522. X    }
  523. X    DEBUG_RETURN(Remove_Tile);
  524. X
  525. X} /* Remove_Tile */
  526. X
  527. X
  528. Xstatic void Touch_Tile( bp, row, col, event )
  529. X     register Board_Position     bp;
  530. X     register XButtonEvent    *event;
  531. X/******************************************************************************
  532. X* Called when we click on a specific tile.  We decide what to do.  For a
  533. X* single click we hilite the tile unless we already have two tiles hilited.
  534. X* For a "double" click with two tiles hilited we will remove both of the
  535. X* tiles.
  536. X******************************************************************************/
  537. X{
  538. X
  539. X/*--If there is no Click1 then this guy becomes it. */
  540. X
  541. X    DEBUG_CALL(Touch_Tile);
  542. X    if (Click1 == Board_Position_NULL) {
  543. X    Click1 = bp;
  544. X    Click1_Row = row;
  545. X    Click1_Col = col;
  546. X    Hilite_Tile( row, col );
  547. X    DEBUG_RETURN(Touch_Tile);
  548. X    return;
  549. X    }
  550. X
  551. X/*--If there is no Click2 then this guy becomes it unless he is already Click1.
  552. X */
  553. X
  554. X    if (Click1 != bp) {
  555. X    if (Click2_Row == row &&
  556. X        Click2_Col == col &&
  557. X        Click2_Time + Dragon_Resources.Double_Click_Time >= event->time) {
  558. X        Click2 = bp;
  559. X    }
  560. X    if( Click2 == Board_Position_NULL) {
  561. X        Click2 = bp;
  562. X        Click2_Row = row;
  563. X        Click2_Col = col;
  564. X        Click2_Time = event->time;
  565. X        Hilite_Tile( row, col );
  566. X        DEBUG_RETURN(Touch_Tile);
  567. X        return;
  568. X    }
  569. X
  570. X/*--If this guy is not one Click1 and not Click2 then we have an error. */
  571. X
  572. X    if (Click2 != bp) {
  573. X        XBell( XtDisplay(Board), 0 );
  574. X        DEBUG_RETURN(Touch_Tile);
  575. X        return;
  576. X    }
  577. X    }
  578. X
  579. X/*--If he double-clicks then remove both tiles. */
  580. X
  581. X    if (Click2 != Board_Position_NULL &&
  582. X    Click2_Time + Dragon_Resources.Double_Click_Time >= event->time) {
  583. X    One_Button_Hint = FALSE;
  584. X    Remove_Tile( Click1, Click1_Row, Click1_Col );
  585. X    Click1 = Board_Position_NULL;
  586. X    Remove_Tile( Click2, Click2_Row, Click2_Col );
  587. X    Click2 = Board_Position_NULL;
  588. X    Score -= 2;
  589. X    Draw_All_Tiles();
  590. X    DEBUG_RETURN(Touch_Tile);
  591. X    return;
  592. X    }
  593. X
  594. X/*--2nd click on any tile means turn-it-off. */
  595. X
  596. X    if (Click1 == bp) {
  597. X    int    s;
  598. X    Hilite_Tile( Click1_Row, Click1_Col );
  599. X    Click1 = Click2;
  600. X    s = Click1_Row;
  601. X    Click1_Row = Click2_Row;
  602. X    Click2_Row = s;
  603. X    s = Click1_Col;
  604. X    Click1_Col = Click2_Col;
  605. X    Click2_Col = s;;
  606. X    Click2 = Board_Position_NULL;
  607. X    } else {
  608. X    Click2 = Board_Position_NULL;
  609. X    Hilite_Tile( Click2_Row, Click2_Col );
  610. X    }
  611. X    Click2_Time = event->time;
  612. X    DEBUG_RETURN(Touch_Tile);
  613. X
  614. X} /* Touch_Tile */
  615. X
  616. X
  617. X/*ARGSUSED*/
  618. Xvoid Tile_Remove( w, event, params, num_params )
  619. X     Widget        w;
  620. X     XButtonEvent    *event;
  621. X     String        *params;
  622. X     Cardinal        *num_params;
  623. X/******************************************************************************
  624. X* Called when the remove-selected-tile-pair mouse button is pressed.
  625. X******************************************************************************/
  626. X{
  627. X
  628. X    DEBUG_CALL(Tile_Remove);
  629. X    if (Click1 != Board_Position_NULL &&
  630. X    Click2 != Board_Position_NULL) {
  631. X    Click2_Time = event->time;
  632. X    Touch_Tile( Click2, Click2_Row, Click2_Col, event );
  633. X    }
  634. X    DEBUG_RETURN(Tile_Remove);
  635. X
  636. X} /* Tile_Remove */
  637. X
  638. X
  639. Xstatic Boolean Touch( bp, event )
  640. X     register Board_Position     bp;
  641. X     register XButtonEvent    *event;
  642. X/******************************************************************************
  643. X* Return TRUE if this XButtonEvent touched this Board_Position.
  644. X******************************************************************************/
  645. X{
  646. X    int        face_x = bp->x + bp->level * Side_X;
  647. X    int        face_y = bp->y - bp->level * Side_Y;
  648. X
  649. X/*--Does this tile exist? */
  650. X
  651. X    DEBUG_CALL(Touch);
  652. X    if (bp->level == 0) {
  653. X    DEBUG_RETURN(Touch);
  654. X    return FALSE;
  655. X    }
  656. X
  657. X/*--Did we touch the face? */
  658. X
  659. X    if (event->x >= face_x && event->x <= face_x + Tile_Width + 1 &&
  660. X    event->y >= face_y && event->y <= face_y + Tile_Height + 1) {
  661. X    DEBUG_RETURN(Touch);
  662. X    return TRUE;
  663. X    }
  664. X
  665. X/*--Did we touch the side? */
  666. X
  667. X    if (event->x >= bp->x && event->x <= bp->x + Tile_Width + 1 &&
  668. X    event->y >= bp->y && event->y <= bp->y + Tile_Height + 1) {
  669. X    DEBUG_RETURN(Touch);
  670. X    return TRUE;
  671. X    }
  672. X
  673. X/*--Guess not. */
  674. X
  675. X    DEBUG_RETURN(Touch);
  676. X    return FALSE;
  677. X
  678. X} /* Touch */
  679. X
  680. X
  681. X/*ARGSUSED*/
  682. Xvoid Tile_Press( w, event, params, num_params )
  683. X          Widget         w;
  684. X     register XButtonEvent    *event;
  685. X          String        *params;
  686. X          Cardinal        *num_params;
  687. X/******************************************************************************
  688. X* Called when the Board receives a BtnDown event.
  689. X******************************************************************************/
  690. X{
  691. X    register Board_Position    bp;
  692. X    int        x;
  693. X    int        y;
  694. X    int        row;
  695. X    int        col;
  696. X
  697. X/*--Figure out a rough row/col coordinate for the click. */
  698. X
  699. X    DEBUG_CALL(Tile_Press);
  700. X    y = event->y - Board_Tile0_Y;
  701. X    if (y < 0) { return; }
  702. X    row = y / (Tile_Height + 1);
  703. X    if (row > 7) { return; }
  704. X    x = event->x - Board_Tile0_X;
  705. X    if (x < 0) { return; }
  706. X    col = x / (Tile_Width + 1);
  707. X    if (col < 0 || row > 14) { goto Touched; }
  708. X
  709. X/*--See if we are a special tile. */
  710. X
  711. X    if (col == 0) {
  712. X    if (Touch( bp = &Board_Tiles[SPEC3], event )) {
  713. X        Touch_Tile( bp, SPEC3row, SPEC3col, event );
  714. X        goto Touched;
  715. X    }
  716. X    goto Touched;
  717. X    } else if (col == 13) {
  718. X    if (Touch( bp = &Board_Tiles[SPEC2], event )) {
  719. X        Touch_Tile( bp, SPEC2row, SPEC2col, event );
  720. X        goto Touched;
  721. X    }
  722. X    if (Touch( bp = &Board_Tiles[4][12], event )) {
  723. X        Touch_Tile( bp, 4, 12, event );
  724. X        goto Touched;
  725. X    }
  726. X    if (Touch( bp = &Board_Tiles[3][12], event )) {
  727. X        Touch_Tile( bp, 3, 12, event );
  728. X        goto Touched;
  729. X    }
  730. X    goto Touched;
  731. X    } else if (col == SPEC1col) {
  732. X    if (Touch( bp = &Board_Tiles[SPEC1], event )) {
  733. X        Touch_Tile( bp, SPEC1row, SPEC1col, event );
  734. X        goto Touched;
  735. X    }
  736. X    if (Touch( bp = &Board_Tiles[SPEC2], event )) {
  737. X        Touch_Tile( bp, SPEC2row, SPEC2col, event );
  738. X        goto Touched;
  739. X    }
  740. X    goto Touched;
  741. X    } else if ((row == 3 || row == 4) && (col == 6 || col == 7)) {
  742. X    if (Touch( bp = &Board_Tiles[SPEC4], event )) {
  743. X        Touch_Tile( bp, SPEC4row, SPEC4col, event );
  744. X        goto Touched;
  745. X    }
  746. X    }
  747. X
  748. X/*--See if the x/y falls exactly into somebody else's tile face. */
  749. X
  750. X    if (col > 0 && row < 7) {
  751. X    if (Touch( bp = &Board_Tiles[row+1][col-1], event )) {
  752. X        Touch_Tile( bp, row+1, col-1, event );
  753. X        goto Touched;
  754. X    }
  755. X    }
  756. X    if (row < 7) {
  757. X    if (Touch( bp = &Board_Tiles[row+1][col], event )) {
  758. X        Touch_Tile( bp, row+1, col, event );
  759. X        goto Touched;
  760. X    }
  761. X    }
  762. X    if (col > 0) {
  763. X    if (Touch( bp = &Board_Tiles[row][col-1], event )) {
  764. X        Touch_Tile( bp, row, col-1, event );
  765. X        goto Touched;
  766. X    }
  767. X    }
  768. X
  769. X/*--We don't have a touch on a neighbor so it must be us. */
  770. X
  771. X    if (Touch( bp = &Board_Tiles[row][col], event )) {
  772. X    Touch_Tile( bp, row, col, event );
  773. X    goto Touched;
  774. X    }
  775. X
  776. X  Touched :
  777. X    DEBUG_RETURN(Tile_Press);
  778. X
  779. X} /* Tile_Press */
  780. X
  781. X
  782. Xstatic Boolean Tile_Not_Free( row, col )
  783. X     int    row;
  784. X     int    col;
  785. X/******************************************************************************
  786. X* Returns TRUE if the tile has neither a left nor a right side free.
  787. X******************************************************************************/
  788. X{
  789. X
  790. X/*--The 4 in the center can be covered by SPEC4. */
  791. X
  792. X    if (row == 3 || row == 4) {
  793. X    if ((col == 6 || col == 7) &&
  794. X        Board_Tiles[SPEC4].level > 0) { return TRUE; }
  795. X    else if (col == 1 &&
  796. X         Board_Tiles[SPEC3].level > 0 &&
  797. X         Board_Tiles[row][col+1].level > 0) { return TRUE; }
  798. X    else if (col == 12 &&
  799. X         Board_Tiles[SPEC2].level > 0 &&
  800. X         Board_Tiles[row][col-1].level > 0) { return TRUE; }
  801. X    }
  802. X    
  803. X/*--If a tile has a neighbor then he isn't free. */
  804. X
  805. X    if (Board_Tiles[row][col-1].level >= Board_Tiles[row][col].level &&
  806. X    Board_Tiles[row][col+1].level >= Board_Tiles[row][col].level) {
  807. X    return TRUE;
  808. X    }
  809. X
  810. X/*--Check the special tiles. */
  811. X
  812. X    if (col == SPEC1col) {
  813. X
  814. X/*--Tiles 1, 3, and 4 are always free. */
  815. X
  816. X    if (row != SPEC2row) { return FALSE; }
  817. X
  818. X/*--Tile 2 is free if tile 1 is gone or if its two normal neighbors are gone.*/
  819. X
  820. X    if (Board_Tiles[SPEC1].level > 0 &&
  821. X        (Board_Tiles[3][12].level > 0 ||
  822. X         Board_Tiles[4][12].level > 0)) { return TRUE; }
  823. X    }
  824. X    return FALSE;
  825. X
  826. X} /* Tile_Not_Free */
  827. X
  828. X
  829. X/*ARGSUSED*/
  830. Xvoid Tile_Release( w, event, params, num_params )
  831. X     Widget    w;
  832. X     XEvent    *event;
  833. X     String    *params;
  834. X     Cardinal    *num_params;
  835. X/******************************************************************************
  836. X* Called when the Board receives a BtnUp event.
  837. X******************************************************************************/
  838. X{
  839. X    extern int    Cheating;
  840. X
  841. X/*--If there is a Click2 and if the tile type does not match with Click1 then
  842. X *  unhilite Click2. */
  843. X
  844. X    DEBUG_CALL(Tile_Release);
  845. X    if (!Cheating &&
  846. X    Click1 != Board_Position_NULL &&
  847. X    Click2 != Board_Position_NULL) {
  848. X    int        tile1, tile2;
  849. X
  850. X    tile1 = Click1->tiles[Click1->level-1];
  851. X    tile2 = Click2->tiles[Click2->level-1];
  852. X    if (/* Do tile faces match for those types that must match exactly? */
  853. X        ((tile1 > 8 || tile2 > 8) && tile1 != tile2) ||
  854. X        /* Are both tiles seasons? */
  855. X        (tile1 <= 4 && tile2 > 4) ||
  856. X        /* Are both tiles flowers? */
  857. X        (tile1 >= 5 && tile1 <= 8 && (tile2 < 5 || tile2 > 8))) {
  858. X        /* They don't match. */
  859. X        if (Dragon_Resources.Sticky_Tile) {
  860. X        /* Simply remove tile 2 from selected tiles. */
  861. X        Hilite_Tile( Click2_Row, Click2_Col );
  862. X        } else {
  863. X        /* Remove tile 1 from selection and make tile 2 => tile 1.*/
  864. X        Hilite_Tile( Click1_Row, Click1_Col );
  865. X         Click1         = Click2;
  866. X         Click1_Row  = Click2_Row;
  867. X         Click1_Col  = Click2_Col;
  868. X        Click2_Col  = 0;    /* Prevent dbl-clk removing 1 tile. */
  869. X        }
  870. X        Click2      = Board_Position_NULL;
  871. X        Click2_Time = 0;
  872. X    }
  873. X    }
  874. X
  875. X/*--If this tile has a left or a right neighbor then he isn't allowed. */
  876. X
  877. X    if (!Cheating) {
  878. X    if (Click2 != Board_Position_NULL &&
  879. X        Tile_Not_Free( Click2_Row, Click2_Col)) {
  880. X        Hilite_Tile( Click2_Row, Click2_Col );
  881. X        Click2 = Board_Position_NULL;
  882. X        Click2_Time = 0;
  883. X    }
  884. X    if (Click1 != Board_Position_NULL &&
  885. X        Tile_Not_Free( Click1_Row, Click1_Col)) {
  886. X        Hilite_Tile( Click1_Row, Click1_Col );
  887. X        Click1 = Board_Position_NULL;
  888. X    }
  889. X    }
  890. X
  891. X    DEBUG_RETURN(Tile_Release);
  892. X
  893. X} /* Tile_Release */
  894. X
  895. X
  896. Xstatic void Next_Tile( Click, row, col )
  897. X     int     Click;
  898. X     int    *row;
  899. X     int    *col;
  900. X/******************************************************************************
  901. X* Returns the "next" tile past row/col that exists and is "free".  Returns 0,0
  902. X* when we run out of tiles.
  903. X******************************************************************************/
  904. X{
  905. X    int        tile1, tile2;
  906. X
  907. X/*--Loop until we give up.  Advance the column.  Advance the row on column
  908. X *  overflow.  Give up on row overflow. */
  909. X
  910. X    DEBUG_CALL(Next_Tile);
  911. X    for (;;) {
  912. X    ++*col;
  913. X    if (*col > 14) {
  914. X        *col = 1;
  915. X        ++*row;
  916. X        if (*row > 7) {
  917. X        *row = 0;
  918. X        *col = 0;
  919. X        break;
  920. X        }
  921. X    }
  922. X
  923. X/*--Check this tile.  If it doesn't exist or isn't free then ignore it. */
  924. X
  925. X    if (Board_Tiles[*row][*col].level == 0) { continue; }
  926. X    if (Tile_Not_Free( *row, *col )) { continue; }
  927. X
  928. X/*--If moving Click1 then return now. */
  929. X
  930. X    if (Click == 1) { break; }
  931. X
  932. X/*--Continue the search if this tile does not match Click1. */
  933. X
  934. X    tile1 =  Click1->tiles[Click1->level-1];
  935. X    tile2 = Board_Tiles[*row][*col].tiles[Board_Tiles[*row][*col].level-1];
  936. X    if (/* Do tile faces match for those types that must match exactly? */
  937. X        ((tile1 > 8 || tile2 > 8) && tile1 != tile2) ||
  938. X        /* Are both tiles seasons? */
  939. X        (tile1 <= 4 && tile2 > 4) ||
  940. X        /* Are both tiles flowers? */
  941. X        (tile1 >= 5 && tile1 <= 8 && (tile2 < 5 || tile2 > 8))) {
  942. X        /* They don't match. */
  943. X        continue;
  944. X    }
  945. X    break;
  946. X    }
  947. X    DEBUG_RETURN(Next_Tile);
  948. X
  949. X} /* Next_Tile */
  950. X
  951. X
  952. X/*ARGSUSED*/
  953. Xvoid Hints( w, event, params, num_params )
  954. X     Widget        w;
  955. X     XButtonEvent    *event;
  956. X     String        *params;
  957. X     Cardinal        *num_params;
  958. X/******************************************************************************
  959. X* If Click1 not present then search for the "first" remaining tile otherwise
  960. X* use Click1 as our current "base" tile.
  961. X* If Click1 present but not Click2 then search for any match for Click1.
  962. X* If Click2 not present either then search for the first remaining tile past 
  963. X* Click1 otherwise search for the first remaining tile past Click2.
  964. X* Keep searching for a new Click2 until we hit a matching tile or until we
  965. X* run out.  Exit on match with new tile as Click2.
  966. X* Advance Click1 and start a new search for Click2.  If we run out on Click1
  967. X* then remove Click1.
  968. X******************************************************************************/
  969. X{
  970. X
  971. X/*--If we have a Click1 but no Click2 then search for a Click2. */
  972. X
  973. X    if (Click1 != Board_Position_NULL &&
  974. X    Click2 == Board_Position_NULL) {
  975. X    One_Button_Hint = TRUE;
  976. X    Click2_Row = 0;
  977. X    Click2_Col = 0;
  978. X    for (;;) {
  979. X        Next_Tile( 2, &Click2_Row, &Click2_Col );
  980. X        if (Click2_Col == 0) {
  981. X        One_Button_Hint = FALSE;
  982. X        Hilite_Tile( Click1_Row, Click1_Col );
  983. X        Click1 = Board_Position_NULL;
  984. X        DEBUG_RETURN(Hints);
  985. X        return;
  986. X        }
  987. X        if (Click2_Row != Click1_Row ||
  988. X        Click2_Col != Click1_Col) {
  989. X        Click2 = &Board_Tiles[Click2_Row][Click2_Col];
  990. X        Hilite_Tile( Click2_Row, Click2_Col );
  991. X        DEBUG_RETURN(Hints);
  992. X        return;
  993. X        }
  994. X    }
  995. X    }
  996. X
  997. X/*--Find a Click1 to work with if we don't already have one. */
  998. X
  999. X    DEBUG_CALL(Hints);
  1000. X    if (Click1 == Board_Position_NULL) {
  1001. X    Click1_Row = 0;
  1002. X    Click1_Col = 0;
  1003. X    Next_Tile( 1, &Click1_Row, &Click1_Col );
  1004. X    if (Click1_Col == 0) { 
  1005. X        DEBUG_RETURN(Hints);
  1006. X        return;
  1007. X    }
  1008. X    Hilite_Tile( Click1_Row, Click1_Col );
  1009. X    Click1 = &Board_Tiles[Click1_Row][Click1_Col];
  1010. X    }
  1011. X
  1012. X/*--Find our starting position for Click2 if we don't have one. */
  1013. X
  1014. X    if (Click2 == Board_Position_NULL) {
  1015. X    Click2_Row = Click1_Row;
  1016. X    Click2_Col = Click1_Col;
  1017. X    } else {
  1018. X    Hilite_Tile( Click2_Row, Click2_Col );
  1019. X    Click2 = Board_Position_NULL;
  1020. X    }
  1021. X
  1022. X/*--Loop until we get something. */
  1023. X
  1024. X    for (;;) {
  1025. X    Next_Tile( 2, &Click2_Row, &Click2_Col );
  1026. X    if (Click2_Col != 0) {
  1027. X        if (Click2_Row != Click1_Row ||
  1028. X        Click2_Col != Click1_Col) {
  1029. X        Click2 = &Board_Tiles[Click2_Row][Click2_Col];
  1030. X        Hilite_Tile( Click2_Row, Click2_Col );
  1031. X        DEBUG_RETURN(Hints);
  1032. X        return;
  1033. X        }
  1034. X    } else {
  1035. X        Hilite_Tile( Click1_Row, Click1_Col );
  1036. X        Click1 = Board_Position_NULL;
  1037. X        if (One_Button_Hint) {
  1038. X        One_Button_Hint = FALSE;
  1039. X        return;
  1040. X        }
  1041. X        Next_Tile( 1, &Click1_Row, &Click1_Col );
  1042. X        if (Click1_Col == 0) {
  1043. X        DEBUG_RETURN(Hints);
  1044. X        return;
  1045. X        }
  1046. X        Hilite_Tile( Click1_Row, Click1_Col );
  1047. X        Click1 = &Board_Tiles[Click1_Row][Click1_Col];
  1048. X        Click2_Row = Click1_Row;
  1049. X        Click2_Col = Click1_Col;
  1050. X    }
  1051. X    }
  1052. X
  1053. X} /* Hints */
  1054. END_OF_FILE
  1055. if test 27424 -ne `wc -c <'board.c'`; then
  1056.     echo shar: \"'board.c'\" unpacked with wrong size!
  1057. fi
  1058. # end of 'board.c'
  1059. fi
  1060. if test -f 'draw.c' -a "${1}" != "-c" ; then 
  1061.   echo shar: Will not clobber existing file \"'draw.c'\"
  1062. else
  1063. echo shar: Extracting \"'draw.c'\" \(30627 characters\)
  1064. sed "s/^X//" >'draw.c' <<'END_OF_FILE'
  1065. X/******************************************************************************
  1066. X* Dragon - a version of Mah-Jongg for X Windows
  1067. X*
  1068. X* Author: Gary E. Barnes    May 1989
  1069. X*
  1070. X* draw.c - Deals with the Mah-Jongg board.  Setup and drawing.
  1071. X******************************************************************************/
  1072. X
  1073. X#include "main.h"
  1074. X#include "board.h"
  1075. X
  1076. Xextern long time();
  1077. X
  1078. Xstatic void Board_Expose();
  1079. Xextern void Button_Expose();
  1080. Xextern void Button_Press();
  1081. Xextern void Button_Release();
  1082. Xextern void Do_Button_Configuration();
  1083. Xextern void Draw_Text();
  1084. Xextern void Draw_Score();
  1085. X
  1086. Xextern void Draw_Spring();
  1087. Xextern void Draw_Summer();
  1088. Xextern void Draw_Fall();
  1089. Xextern void Draw_Winter();
  1090. Xextern void Draw_Bamboo();
  1091. Xextern void Draw_Mum();
  1092. Xextern void Draw_Orchid();
  1093. Xextern void Draw_Plum();
  1094. Xextern void Draw_GDragon();
  1095. Xextern void Draw_RDragon();
  1096. Xextern void Draw_WDragon();
  1097. Xextern void Draw_East();
  1098. Xextern void Draw_West();
  1099. Xextern void Draw_North();
  1100. Xextern void Draw_South();
  1101. Xextern void Draw_Bam1();
  1102. Xextern void Draw_Bam2();
  1103. Xextern void Draw_Bam3();
  1104. Xextern void Draw_Bam4();
  1105. Xextern void Draw_Bam5();
  1106. Xextern void Draw_Bam6();
  1107. Xextern void Draw_Bam7();
  1108. Xextern void Draw_Bam8();
  1109. Xextern void Draw_Bam9();
  1110. Xextern void Draw_Dot1();
  1111. Xextern void Draw_Dot2();
  1112. Xextern void Draw_Dot3();
  1113. Xextern void Draw_Dot4();
  1114. Xextern void Draw_Dot5();
  1115. Xextern void Draw_Dot6();
  1116. Xextern void Draw_Dot7();
  1117. Xextern void Draw_Dot8();
  1118. Xextern void Draw_Dot9();
  1119. Xextern void Draw_Crak1();
  1120. Xextern void Draw_Crak2();
  1121. Xextern void Draw_Crak3();
  1122. Xextern void Draw_Crak4();
  1123. Xextern void Draw_Crak5();
  1124. Xextern void Draw_Crak6();
  1125. Xextern void Draw_Crak7();
  1126. Xextern void Draw_Crak8();
  1127. Xextern void Draw_Crak9();
  1128. X
  1129. X/*--Index into this array using a tile number in order to get the procedure
  1130. X *  that knows how to draw the face of that tile. */
  1131. X
  1132. Xtypedef void (*Draw_Xyz)();
  1133. X
  1134. Xvoid Draw_Error() { (void)fprintf( stderr, "Drew tile face 0??\n" ); return; }
  1135. X
  1136. XDraw_Xyz    Faces[1+NFACES] = {
  1137. X    Draw_Error,
  1138. X
  1139. X    Draw_Spring,  Draw_Summer,  Draw_Fall,    Draw_Winter,
  1140. X
  1141. X    Draw_Bamboo,  Draw_Mum,     Draw_Orchid,  Draw_Plum,
  1142. X
  1143. X    Draw_GDragon, Draw_RDragon, Draw_WDragon,
  1144. X
  1145. X    Draw_East,    Draw_West,    Draw_North,   Draw_South,
  1146. X
  1147. X    Draw_Bam1,    Draw_Bam2,    Draw_Bam3,    Draw_Bam4,     Draw_Bam5,
  1148. X    Draw_Bam6,    Draw_Bam7,    Draw_Bam8,    Draw_Bam9,
  1149. X
  1150. X    Draw_Dot1,    Draw_Dot2,    Draw_Dot3,    Draw_Dot4,     Draw_Dot5,
  1151. X    Draw_Dot6,    Draw_Dot7,    Draw_Dot8,    Draw_Dot9,
  1152. X
  1153. X    Draw_Crak1,   Draw_Crak2,   Draw_Crak3,   Draw_Crak4,    Draw_Crak5,
  1154. X    Draw_Crak6,   Draw_Crak7,   Draw_Crak8,   Draw_Crak9
  1155. X};
  1156. X
  1157. X
  1158. Xvoid Hilite_Tile( row, col )
  1159. X     int    row;
  1160. X     int    col;
  1161. X/******************************************************************************
  1162. X*   row    - Specifies the row of the tile to hilite
  1163. X*   col - specifies the column of the tile to hilite
  1164. X*
  1165. X* Called to hilite a tile face.
  1166. X******************************************************************************/
  1167. X{
  1168. X    register Board_Position    bp = &Board_Tiles[row][col];
  1169. X    XPoint    pnts[20];
  1170. X    int        pnti = 0;
  1171. X    int        x, y, w, h;
  1172. X    int        left, bottom, left_bottom;
  1173. X
  1174. X#define PNT(X,Y) \
  1175. X    DEBUG_ERROR(pnti >= XtNumber(pnts),"HT pnts overflow!\n"); \
  1176. X    pnts[pnti].x = X;     pnts[pnti].y = Y;  ++pnti
  1177. X    ;
  1178. X
  1179. X/*--See if we are one of the very special tiles on top. */
  1180. X
  1181. X    DEBUG_CALL(Hilite_Tile);
  1182. X    if (Board_Tiles[SPEC4].level > 0) {
  1183. X    if (row == 3) {
  1184. X        if (col == 6) {
  1185. X        x = bp->x + Side_X * 4 + 1;
  1186. X        y = bp->y - Side_Y * 4 + 1;
  1187. X        w = Tile_Width / 2;
  1188. X        h = Tile_Height / 2;
  1189. X        PNT( x,            y );
  1190. X        PNT( Tile_Width,    0 );
  1191. X        PNT( 0,            h-1 );
  1192. X        PNT( -(w+1),         0 );
  1193. X        PNT( 0,            h+1 );
  1194. X        PNT( -(w-1),        0 );
  1195. X        PNT( 0,            -Tile_Height );
  1196. X        goto Hilite;
  1197. X        } else if (col == 7) {
  1198. X        x = bp->x + Side_X * 4 + 1;
  1199. X        y = bp->y - Side_Y * 4 + 1;
  1200. X        w = Board_Tiles[3][7].x - Board_Tiles[SPEC4].x + 3 * Side_X;
  1201. X        h = Tile_Height / 2;
  1202. X        PNT( x,            y );
  1203. X        PNT( Tile_Width,    0 );
  1204. X        PNT( 0,            Tile_Height );
  1205. X        PNT( -w,        0 );
  1206. X        PNT( 0,            -(h+1) );
  1207. X        PNT( -(Tile_Width-w),     0 );
  1208. X        PNT( 0,            -(h-1) );
  1209. X        goto Hilite;
  1210. X        }
  1211. X    } else if (row == 4) {
  1212. X        if (col == 6) {
  1213. X        x = bp->x + Side_X * 4 + 1;
  1214. X        y = bp->y - Side_Y * 4 + 1;
  1215. X        w = Tile_Width / 2;
  1216. X        h = Tile_Height / 2;
  1217. X        PNT( x,            y );
  1218. X        PNT( w-1,        0 );
  1219. X        PNT( 0,            h + Side_Y );
  1220. X        PNT( w+1,        0 );
  1221. X        PNT( 0,            h - Side_Y );
  1222. X        PNT( -Tile_Width,    0 );
  1223. X        PNT( 0,            -Tile_Height );
  1224. X        goto Hilite;
  1225. X        } else if (col == 7) {
  1226. X        x = bp->x + Side_X * 4 + 1;
  1227. X        y = bp->y - Side_Y * 4 + 1;
  1228. X        w = Board_Tiles[4][7].x - Board_Tiles[SPEC4].x + 3 * Side_X;
  1229. X        h = Tile_Height / 2;
  1230. X        PNT( x + Tile_Width - w,    y );
  1231. X        PNT( w,                0 );
  1232. X        PNT( 0,                Tile_Height );
  1233. X        PNT( -Tile_Width,        0 );
  1234. X        PNT( 0,                -(h - Side_Y) );
  1235. X        PNT( Tile_Width - w,        0 );
  1236. X        PNT( 0,                -(h + Side_Y) );
  1237. X        goto Hilite;
  1238. X        }
  1239. X    }
  1240. X    }
  1241. X
  1242. X/*--We are a normal tile that may be partially overlapped by some other
  1243. X *  normal tile. */
  1244. X
  1245. X    x = bp->x + Side_X * bp->level + 1;
  1246. X    y = bp->y - Side_Y * bp->level + 1;
  1247. X    w = Tile_Width;
  1248. X    h = Tile_Height;
  1249. X    if (col > 0) {
  1250. X    left = Board_Tiles[row][col-1].level - bp->level;
  1251. X    if (left < 0) { left = 0; }
  1252. X    if (row < 7) {
  1253. X        left_bottom = Board_Tiles[row+1][col-1].level - bp->level;
  1254. X        if (left_bottom < 0) { left_bottom = 0; }
  1255. X    } else {
  1256. X        left_bottom = 0;
  1257. X    }
  1258. X    } else {
  1259. X    left = 0;
  1260. X    left_bottom = 0;
  1261. X    }
  1262. X    if (row < 7) {
  1263. X    bottom = Board_Tiles[row+1][col].level - bp->level;
  1264. X    if (bottom < 0) { bottom = 0; }
  1265. X    } else {
  1266. X    bottom = 0;
  1267. X    }
  1268. X    if (bottom > left_bottom && Tile_Width == 28) { left_bottom = bottom; }
  1269. X    if (left > 0) {
  1270. X    w = left * Side_X;
  1271. X    } else {
  1272. X    w = 0;
  1273. X    }
  1274. X    PNT( x + w, y );
  1275. X    PNT( Tile_Width - w, 0 );
  1276. X    if (bottom > 0) {
  1277. X    h = bottom * Side_Y;
  1278. X    } else {
  1279. X    h = 0;
  1280. X    }
  1281. X    PNT( 0, Tile_Height - h );
  1282. X    if (left_bottom <= left && left_bottom <= bottom) {
  1283. X    PNT( -(Tile_Width - bottom*Side_X), 0 );
  1284. X    if (left != bottom) {
  1285. X        PNT( (left-bottom)*Side_X, (bottom-left)*Side_Y );
  1286. X    }
  1287. X    PNT( 0, -(Tile_Height - h) );
  1288. X    } else if (left_bottom <= left) {    /* left_bottom > bottom */
  1289. X    PNT( -(Tile_Width - left_bottom*Side_X), 0 );
  1290. X    if (left_bottom != left ) {
  1291. X        PNT( 0, (bottom-left_bottom)*Side_Y );
  1292. X        PNT( (left-left_bottom)*Side_X, (left_bottom-left)*Side_Y );
  1293. X        PNT( 0, -(Tile_Height - left * Side_Y) );
  1294. X    } else {
  1295. X        PNT( 0, -(Tile_Height - h) );
  1296. X    }
  1297. X    } else if (left_bottom <= bottom) {    /* left_bottom > left */
  1298. X    if (left_bottom == bottom) {
  1299. X        PNT( -(Tile_Width-w), 0 );
  1300. X        PNT( 0, -(Tile_Height-h) );
  1301. X    } else {
  1302. X        PNT( -(Tile_Width - bottom * Side_X), 0 );
  1303. X        PNT( (left_bottom-bottom)*Side_X, (bottom-left_bottom)*Side_Y );
  1304. X        PNT( -left_bottom*Side_X, 0 );
  1305. X        PNT( 0, -(Tile_Height - left_bottom * Side_Y) );
  1306. X    }
  1307. X    } else {        /* left_bottom > bottom && left_bottom > left */
  1308. X    PNT( -(Tile_Width - left_bottom * Side_X), 0 );
  1309. X    PNT( 0, (bottom-left_bottom)*Side_Y );
  1310. X    PNT( (left-left_bottom)*Side_X, 0 );
  1311. X    PNT( 0, -(Tile_Height - left_bottom * Side_Y) );
  1312. X    }
  1313. X
  1314. X/*--Now do it. */
  1315. X
  1316. X  Hilite :
  1317. X    XFillPolygon( XtDisplay(Board), XtWindow(Board), Xor_GC,
  1318. X          pnts, (Cardinal)pnti, Convex, CoordModePrevious );
  1319. X    DEBUG_RETURN(Hilite_Tile);
  1320. X
  1321. X} /* Hilite_Tile */
  1322. X
  1323. X
  1324. Xstatic void Clear_Tile( bp, left, bottom )
  1325. X     register Board_Position    bp;
  1326. X     int            left;
  1327. X     int            bottom;
  1328. X/******************************************************************************
  1329. X*   bp        - Specifies the Board_Position to draw
  1330. X*   left    - Specifies the level of the tile on the left of this thile
  1331. X*   bottom  - Specifies the level of the tile at the bottom of this tile
  1332. X*
  1333. X* We clear (make totally white) the space occupied by the image of this tile.
  1334. X* We clear the face and the left and bottom sides.  Any shadowing caused by
  1335. X* the last drawing of this tile is the responsibility of the caller.
  1336. X******************************************************************************/
  1337. X{
  1338. X    XPoint    Poly[10];
  1339. X    int        Polyi;
  1340. X
  1341. X#undef PNT
  1342. X#define PNT(XX,YY) \
  1343. X    DEBUG_ERROR(Polyi >= XtNumber(Poly),"Tile: Poly overflow!!\n" ); \
  1344. X    Poly[Polyi].x = (XX); \
  1345. X    Poly[Polyi].y = (YY); \
  1346. X    ++Polyi
  1347. X    ;
  1348. X
  1349. X/*--We will circle the tile outline clockwise. */
  1350. X
  1351. X    DEBUG_CALL(Clear_Tile);
  1352. X    Polyi = 0;
  1353. X
  1354. X/*--Start with the upper left corner of the tile side. This is the "bottom"
  1355. X *  of that tile side if it has one. Leave x/y at the upper-left corner of the
  1356. X *  tile face. */
  1357. X
  1358. X    if (left >= bp->level) {
  1359. X    left = bp->level;
  1360. X    PNT( bp->x + Side_X * bp->level, bp->y - Side_Y * bp->level );
  1361. X    } else {
  1362. X    PNT( bp->x + Side_X * left, bp->y - Side_Y * left );
  1363. X    PNT( Side_X * (bp->level - left), - Side_Y * (bp->level - left) );
  1364. X    }
  1365. X
  1366. X/*--Cross the top and the right side of the tile. */
  1367. X
  1368. X    PNT( Tile_Width + 1, 0 );
  1369. X    PNT( 0, Tile_Height + 1 );
  1370. X
  1371. X/*--Now do the bottom side of the tile. */
  1372. X
  1373. X    if (bottom < bp->level) {
  1374. X    PNT( - Side_X * (bp->level - bottom), Side_Y * (bp->level - bottom) );
  1375. X    } else {
  1376. X    bottom = bp->level;
  1377. X    }
  1378. X    PNT( -(Tile_Width + 1), 0 );
  1379. X
  1380. X/*--Now go up the left side of the tile. */
  1381. X
  1382. X    if (left != bottom) {
  1383. X    PNT( Side_X * (left - bottom), - Side_Y * (left - bottom) );
  1384. X    }
  1385. X    PNT( 0, -(Tile_Height + 1) );
  1386. X
  1387. X/*--Do the actual clearing. */
  1388. X
  1389. X    XFillPolygon( XtDisplay(Board), XtWindow(Board), Reverse_GC,
  1390. X          Poly, (Cardinal)Polyi, Convex, CoordModePrevious );
  1391. X    DEBUG_RETURN(Clear_Tile);
  1392. X
  1393. X} /* Clear_Tile */
  1394. X
  1395. X
  1396. Xstatic void Tile( row, col )
  1397. X     int        row;
  1398. X     int        col;
  1399. X/******************************************************************************
  1400. X*   row          - Specifies the tile to draw
  1401. X*   col          - Specifies the tile to draw
  1402. X*
  1403. X* Called to draw a tile.  We draw the face, the sides, and the shadow.
  1404. X******************************************************************************/
  1405. X{
  1406. X    register Board_Position    bp= &Board_Tiles[row][col];
  1407. X    XPoint            Poly[100];
  1408. X    int                Polyi;
  1409. X    int                left;
  1410. X    int                bottom;
  1411. X    int                curx;
  1412. X    int                cury;
  1413. X    int                sidex;
  1414. X    int                sidey;
  1415. X    int                i, j, k, l, m;
  1416. X
  1417. X#undef PNT
  1418. X#define PNT(XX,YY) \
  1419. X    DEBUG_ERROR(Polyi >= XtNumber(Poly), "Tile: Poly overflow!!\n" ); \
  1420. X    Poly[Polyi].x = (XX); \
  1421. X    Poly[Polyi].y = (YY); \
  1422. X    ++Polyi
  1423. X    ;
  1424. X
  1425. X/*--This tile no longer needs drawing. */
  1426. X
  1427. X    DEBUG_CALL(Tile);
  1428. X    bp->draw = FALSE;
  1429. X
  1430. X/*--Determine the level of the tile on the left of this tile. */
  1431. X
  1432. X    if (col > 0) {
  1433. X    if (col == SPEC1col && row == SPEC1row) {
  1434. X        left = Board_Tiles[SPEC2].level;
  1435. X    } else if (col == SPEC2col && row == SPEC2row) {
  1436. X        if (Board_Tiles[3][12].level == 0 ||
  1437. X        Board_Tiles[4][12].level == 0) {
  1438. X        left = 0;
  1439. X        } else {
  1440. X        left = 1;
  1441. X        }
  1442. X    } else {
  1443. X        left = Board_Tiles[row][col-1].level;
  1444. X    }
  1445. X    } else {
  1446. X    left = 0;
  1447. X    }
  1448. X
  1449. X/*--Determine the level of the tile at the bottom of this tile. */
  1450. X
  1451. X    if (row < 7) {
  1452. X    bottom = Board_Tiles[row+1][col].level;
  1453. X    } else {
  1454. X    bottom = 0;
  1455. X    }
  1456. X
  1457. X/*--Clear the area that will be covered by this tile. */
  1458. X
  1459. X    Clear_Tile( bp, left, bottom );
  1460. X
  1461. X/*--Draw the tile face. */
  1462. X
  1463. X    (*(Faces[bp->tiles[bp->level-1]]))( bp->x + bp->level * Side_X + 1,
  1464. X                        bp->y - bp->level * Side_Y + 1 );
  1465. X
  1466. X/*--Now draw the tile edges. */
  1467. X
  1468. X    if (Tile_Control & BLACKSIDE) {
  1469. X
  1470. X/*--We want black/gray sides. */
  1471. X
  1472. X    XDrawRectangle( XtDisplay(Board), XtWindow(Board), Normal_GC,
  1473. X                bp->x + bp->level * Side_X,
  1474. X                bp->y - bp->level * Side_Y,
  1475. X                Tile_Width + 1, Tile_Height + 1 );
  1476. X
  1477. X    if (left < bp->level) {
  1478. X        Polyi = 0;
  1479. X        PNT( bp->x + left * Side_X, bp->y - left * Side_Y );
  1480. X        PNT( (bp->level - left) * Side_X, (left - bp->level) * Side_Y );
  1481. X        PNT( 0, Tile_Height + 1 );
  1482. X        PNT( (left - bp->level) * Side_X, (bp->level - left) * Side_Y );
  1483. X        PNT( 0, -(Tile_Height + 1) );
  1484. X        XFillPolygon( XtDisplay(Board), XtWindow(Board),
  1485. X              ((Tile_Control & GRAYSIDE) ? Gray_GC : Normal_GC),
  1486. X              Poly, (Cardinal)Polyi, Convex, CoordModePrevious );
  1487. X        XDrawLines( XtDisplay(Board), XtWindow(Board), Normal_GC,
  1488. X               Poly, (Cardinal)Polyi, CoordModePrevious );
  1489. X    }
  1490. X    if (bottom < bp->level) {
  1491. X        Polyi = 0;
  1492. X        PNT( bp->x + bp->level * Side_X,
  1493. X         bp->y - bp->level * Side_Y + Tile_Height + 1 );
  1494. X        PNT( Tile_Width + 1, 0 );
  1495. X        PNT( (bottom - bp->level) * Side_X, (bp->level - bottom) * Side_Y);
  1496. X        PNT( -(Tile_Width + 1), 0 );
  1497. X        PNT( (bp->level - bottom) * Side_X, (bottom - bp->level) * Side_Y);
  1498. X        XFillPolygon( XtDisplay(Board), XtWindow(Board),
  1499. X              ((Tile_Control & GRAYSIDE) ? Gray_GC : Normal_GC),
  1500. X              Poly, (Cardinal)Polyi, Convex, CoordModePrevious );
  1501. X        XDrawLines( XtDisplay(Board), XtWindow(Board), Normal_GC,
  1502. X                Poly, (Cardinal)Polyi, CoordModePrevious );
  1503. X    }
  1504. X
  1505. X/*--We want line'ed sides. */
  1506. X
  1507. X    } else {
  1508. X
  1509. X    Polyi = 0;
  1510. X    if (left >= bp->level) {
  1511. X        PNT( bp->x + Side_X * bp->level, bp->y - Side_Y * bp->level );
  1512. X    } else {
  1513. X
  1514. X/*--First we draw the left side.  We leave x/y at the bottom left corner of
  1515. X *  the tile face when we are done. */
  1516. X
  1517. X#define LSEGS 7 /* keep this an odd number */
  1518. X
  1519. X        sidex = Side_X * (bp->level - left);
  1520. X        sidey = Side_Y * (bp->level - left);
  1521. X        j = sidex;
  1522. X        if (Tile_Width == 28 && bp->level - left == 1) {
  1523. X        PNT( bp->x + Side_X * left, bp->y - Side_Y * left - sidey );
  1524. X        PNT( 0, Tile_Height + 1 + sidey );
  1525. X        k = 0;
  1526. X        } else {
  1527. X        PNT( bp->x + Side_X * left, bp->y - Side_Y * left );
  1528. X        PNT(0, Tile_Height + 1 );
  1529. X        k = sidey;
  1530. X        }
  1531. X        PNT( sidex, -sidey );
  1532. X        i = Tile_Height / (LSEGS+1);
  1533. X        m = Tile_Height - i * (LSEGS+1);
  1534. X        for (l = LSEGS; l > 0; --l) {
  1535. X        cury = -i;
  1536. X        if (m > 0) { cury -= 1; --m; }
  1537. X        PNT( 0, cury );
  1538. X        PNT( -j, k );
  1539. X        j = -j;
  1540. X        k = -k;
  1541. X        }
  1542. X        PNT( 0, -i-1 );
  1543. X        PNT( sidex, k );
  1544. X    }
  1545. X    PNT( 0, Tile_Height + 1 );
  1546. X
  1547. X/*--Draw the left edge of the tile and then draw the bottom side of the tile.
  1548. X *  We leave x/y at the bottom right corner of the tile face when we are done.
  1549. X */
  1550. X
  1551. X#define RSEGS 6    /* keep this an even number */
  1552. X
  1553. X    if (bottom < bp->level) {
  1554. X        sidex = Side_X * (bp->level - bottom);
  1555. X        sidey = Side_Y * (bp->level - bottom);
  1556. X        i = Tile_Width / (RSEGS+1);
  1557. X        m = Tile_Width - i * (RSEGS+1);
  1558. X        if (Tile_Width == 28 && bp->level - bottom == 1) {
  1559. X        j = 0;
  1560. X        } else {
  1561. X        j = sidex;
  1562. X        }
  1563. X        k = sidey;
  1564. X        for (l = RSEGS; l > 0; --l) {
  1565. X        curx = i;
  1566. X        if (m > 0) { curx += 1; --m; }
  1567. X        PNT( curx, 0 );
  1568. X        PNT( -j, k );
  1569. X        j = -j;
  1570. X        k = -k;
  1571. X        }
  1572. X        PNT( i+1, 0 );
  1573. X        PNT( -j, sidey );
  1574. X        PNT( -(Tile_Width + 1 + sidex - j), 0 );
  1575. X        PNT( sidex, -sidey );
  1576. X    }
  1577. X    PNT( Tile_Width + 1, 0 );
  1578. X
  1579. X/*--Draw the right side. */
  1580. X
  1581. X    PNT( 0, -(Tile_Height + 1) );
  1582. X
  1583. X/*--Draw the top side. */
  1584. X
  1585. X    PNT( -(Tile_Width + 1), 0 );
  1586. X
  1587. X/*--Draw all of those edges. */
  1588. X
  1589. X    XDrawLines( XtDisplay(Board), XtWindow(Board),
  1590. X            ((Tile_Control & GRAYSIDE) ? Gray_GC : Normal_GC),
  1591. X            Poly, (Cardinal)Polyi, CoordModePrevious );
  1592. X    }
  1593. X
  1594. X/*--Now draw the tile shadow. */
  1595. X
  1596. X    if (Tile_Control & SHADOW) {
  1597. X    int    top, right;
  1598. X    Boolean    top_right;
  1599. X
  1600. X/*--Determine the level of the tile on the right of this tile. */
  1601. X
  1602. X    if (col == SPEC1col) {
  1603. X        if (row == SPEC2row) {
  1604. X        right = Board_Tiles[SPEC1].level;
  1605. X        } else if (row == SPEC3row) {
  1606. X        right = 0;
  1607. X        } else {
  1608. X        right = 0;
  1609. X        }
  1610. X    } else {
  1611. X        right = Board_Tiles[row][col+1].level;
  1612. X    }
  1613. X
  1614. X/*--Determine the level of the tile at the top of this tile. */
  1615. X
  1616. X    if (row > 0) {
  1617. X        top = Board_Tiles[row-1][col].level;
  1618. X    } else {
  1619. X        top = 0;
  1620. X    }
  1621. X
  1622. X/*--Do we have an upper-right tile? */
  1623. X
  1624. X    if (row > 0 &&
  1625. X        Board_Tiles[row-1][col+1].level >= bp->level) {
  1626. X        top_right = TRUE;
  1627. X    } else if (row == SPEC3row && col == SPEC3col &&
  1628. X           Board_Tiles[3][1].level > 0) {
  1629. X        top_right = TRUE;
  1630. X    } else if (row == 4 && col == 12 &&
  1631. X           Board_Tiles[SPEC2].level > 0) {
  1632. X        top_right = TRUE;
  1633. X    } else {
  1634. X        top_right = FALSE;
  1635. X    }
  1636. X
  1637. X/*--Draw the upper shadow if necessary. */
  1638. X
  1639. X    if (top < bp->level) {
  1640. X        Polyi = 0;
  1641. X        PNT( bp->x + bp->level * Side_X - 1,
  1642. X         bp->y - bp->level * Side_Y );
  1643. X        PNT( Shadow_X, -Shadow_Y );
  1644. X        if (top_right) {
  1645. X        i = Shadow_X;
  1646. X        } else {
  1647. X        i = 0;
  1648. X        }
  1649. X        PNT( Tile_Width + 3 - i, 0 );
  1650. X        PNT( -(Shadow_X - i), Shadow_Y );
  1651. X        PNT( -(Tile_Width + 3), 0 );
  1652. X        XFillPolygon( XtDisplay(Board), XtWindow(Board), Over_GC,
  1653. X              Poly, (Cardinal)Polyi, Convex, CoordModePrevious );
  1654. X    }
  1655. X
  1656. X/*--Now work on the right shadow.  It may need to be drawn in pieces. */
  1657. X
  1658. X    Polyi = 0;
  1659. X
  1660. X/*--If SPEC3 has both neighbors then don't draw the right shadow. */
  1661. X
  1662. X    if (row == SPEC3row && col == SPEC3col) {
  1663. X        if (Board_Tiles[3][1].level > 0) {
  1664. X        if (Board_Tiles[4][1].level > 0) {
  1665. X            right = bp->level;
  1666. X
  1667. X/*--If SPEC3 has only the upper neighbor then draw just the lower shadow. */
  1668. X
  1669. X        } else {
  1670. X            i = bp->y - Board_Tiles[3][1].y;
  1671. X            PNT( Board_Tiles[4][1].x + Side_X, Board_Tiles[4][1].y );
  1672. X            PNT( Shadow_X, 0 );
  1673. X            PNT( 0, i - Shadow_Y);
  1674. X            PNT( -Shadow_X, Shadow_Y );
  1675. X            PNT( 0, -i );
  1676. X            right = bp->level;
  1677. X        }
  1678. X
  1679. X/*--If SPEC3 has only the lower neighbor then draw just the upper shadow. */
  1680. X
  1681. X        } else if (Board_Tiles[4][1].level > 0) {
  1682. X        i = Board_Tiles[4][1].y - bp->y;
  1683. X        PNT( bp->x + bp->level * Side_X + Tile_Width + 1 + 1,
  1684. X             bp->y - bp->level * Side_Y );
  1685. X        PNT( Shadow_X, -Shadow_Y );
  1686. X        PNT( 0, i + Shadow_Y );
  1687. X        PNT( -Shadow_X, 0 );
  1688. X        PNT( 0, -i );
  1689. X        right = bp->level;
  1690. X        }
  1691. X
  1692. X/*--If SPEC2's upper neighbor is there then draw that tile's upper shadow. */
  1693. X
  1694. X    } else if (row == 3 && col == 12 && Board_Tiles[SPEC2].level > 0) {
  1695. X        i = Board_Tiles[SPEC2].y - bp->y;
  1696. X        PNT( bp->x + bp->level * Side_X + Tile_Width + 1 + 1,
  1697. X         bp->y - bp->level * Side_Y );
  1698. X        PNT( Shadow_X, -Shadow_Y );
  1699. X        PNT( 0, i + Shadow_Y );
  1700. X        PNT( -Shadow_X, 0 );
  1701. X        PNT( 0, -i );
  1702. X        right = bp->level;
  1703. X
  1704. X/*--If SPEC2's lower neighbor is there then draw that tile's lower shadow. */
  1705. X
  1706. X    } else if (row == 4 && col == 12 && Board_Tiles[SPEC2].level > 0) {
  1707. X        i = bp->y - Board_Tiles[SPEC2].y;
  1708. X        PNT( Board_Tiles[SPEC2].x + Side_X,
  1709. X         Board_Tiles[SPEC2].y + Tile_Height + 1);
  1710. X        PNT( Shadow_X, 0 );
  1711. X        PNT( 0, i - Shadow_Y);
  1712. X        PNT( -Shadow_X, Shadow_Y );
  1713. X        PNT( 0, -i );
  1714. X        right = bp->level;
  1715. X    }
  1716. X
  1717. X/*--If required, draw a normal right shadow that may be truncated by an upper
  1718. X *  right neighbor. */
  1719. X
  1720. X    if (right < bp->level) {
  1721. X        Polyi = 0;
  1722. X        if (top_right) {
  1723. X        i = Shadow_Y;
  1724. X        } else {
  1725. X        i = 0;
  1726. X        }
  1727. X        PNT( bp->x + bp->level * Side_X + Tile_Width + 1 + 1,
  1728. X         bp->y - bp->level * Side_Y );
  1729. X        PNT( Shadow_X, -(Shadow_Y-i) );
  1730. X        PNT( 0, Tile_Height + 1 - i );
  1731. X        PNT( -Shadow_X, Shadow_Y );
  1732. X        PNT( 0, -(Tile_Height + 1) );
  1733. X    }
  1734. X
  1735. X/*--Draw any right shadow that may have been requested. */
  1736. X
  1737. X    if (Polyi > 0) {
  1738. X        XFillPolygon( XtDisplay(Board), XtWindow(Board), Over_GC,
  1739. X              Poly, (Cardinal)Polyi, Convex, CoordModePrevious );
  1740. X    }
  1741. X    }
  1742. X
  1743. X/*--Now check for hiliting. */
  1744. X
  1745. X    if (Board_State != s_Sample) {
  1746. X    if (Click1 == bp) {
  1747. X        Hilite_Tile( Click1_Row, Click1_Col );
  1748. X    } else if (Click2 == bp) {
  1749. X        Hilite_Tile( Click2_Row, Click2_Col );
  1750. X    }
  1751. X    }
  1752. X    DEBUG_RETURN(Tile);
  1753. X
  1754. X} /* Tile */
  1755. X
  1756. X
  1757. Xvoid Draw_All_Tiles()
  1758. X/******************************************************************************
  1759. X* Draws all visible tiles.
  1760. X******************************************************************************/
  1761. X{
  1762. X    int        i,j;
  1763. X
  1764. X/*--Draw the rightmost special tiles. */
  1765. X
  1766. X    DEBUG_CALL(Draw_All_Tiles);
  1767. X    if (Board_Tiles[SPEC1].draw && Board_Tiles[SPEC1].level > 0) {
  1768. X    Tile( SPEC1row, SPEC1col );
  1769. X    }
  1770. X    if (Board_Tiles[SPEC2].draw && Board_Tiles[SPEC2].level > 0) {
  1771. X    Tile( SPEC2row, SPEC2col );
  1772. X    }
  1773. X
  1774. X/*--Draw the current game.  Draw the normally placed tiles. */
  1775. X
  1776. X    for (i = 0; i <= 7; ++i) {
  1777. X    for (j = 12; j >= 1; --j) {
  1778. X        if (Board_Tiles[i][j].draw && Board_Tiles[i][j].level > 0) {
  1779. X        Tile( i, j );
  1780. X        }
  1781. X    }
  1782. X    }
  1783. X
  1784. X/*--Now draw the other special tiles. */
  1785. X
  1786. X    if (Board_Tiles[SPEC4].draw && Board_Tiles[SPEC4].level > 0) {
  1787. X    Tile( SPEC4row, SPEC4col );
  1788. X    }
  1789. X    if (Board_Tiles[SPEC3].draw && Board_Tiles[SPEC3].level > 0) {
  1790. X    Tile( SPEC3row, SPEC3col );
  1791. X    }
  1792. X    Draw_Score( Score,
  1793. X            (int)(Board_Tile0_X + 14 * (Tile_Width  + 1)),
  1794. X            (int)(Board_Tile0_Y +  8 * (Tile_Height + 1)) );
  1795. X    DEBUG_RETURN(Draw_All_Tiles);
  1796. X
  1797. X} /* Draw_All_Tiles */
  1798. X
  1799. X
  1800. Xstatic void Sample( face, x, y )
  1801. X     int    face;
  1802. X     int    x;
  1803. X     int    y;
  1804. X/******************************************************************************
  1805. X* Draw one sample tile.
  1806. X******************************************************************************/
  1807. X{
  1808. X
  1809. X    XDrawRectangle( XtDisplay(Board), XtWindow(Board), Normal_GC,
  1810. X            x, y, Tile_Width+1, Tile_Height+1 );
  1811. X    (*(Faces[face]))( x+1, y+1 );
  1812. X
  1813. X} /* Sample */
  1814. X
  1815. X
  1816. X/*ARGSUSED*/
  1817. Xstatic void Tile_Samples()
  1818. X/******************************************************************************
  1819. X* Called when we want to display all tiles as a sampler.
  1820. X******************************************************************************/
  1821. X{
  1822. X    int        x = Board_Tile0_X + 2 * Tile_Width;
  1823. X    int        y = Board_Tile0_Y;
  1824. X
  1825. X/*--Clear the board. */
  1826. X
  1827. X    DEBUG_CALL(Tile_Samples);
  1828. X
  1829. X/*--Draw sample tiles. */
  1830. X
  1831. X    Draw_Text( "Flower", Board_Tile0_X, y );
  1832. X    Draw_Text( "Flower", Board_Tile0_X+1, y );
  1833. X    Sample(  5, (int)(x + (Tile_Width + 1)*0), y );/*Draw_Bamboo*/
  1834. X    Sample(  6, (int)(x + (Tile_Width + 1)*1), y );/*Draw_Mum*/
  1835. X    Sample(  7, (int)(x + (Tile_Width + 1)*2), y );/*Draw_Orchid*/
  1836. X    Sample(  8, (int)(x + (Tile_Width + 1)*3), y );/*Draw_Plum*/
  1837. X
  1838. X    y += (int)Tile_Height + 1;
  1839. X    Draw_Text( "Season", Board_Tile0_X, y );
  1840. X    Draw_Text( "Season", Board_Tile0_X+1, y );
  1841. X    Sample(  1, (int)(x + (Tile_Width + 1)*0), y );/*Draw_Spring*/
  1842. X    Sample(  2, (int)(x + (Tile_Width + 1)*1), y );/*Draw_Summer*/
  1843. X    Sample(  3, (int)(x + (Tile_Width + 1)*2), y );/*Draw_Fall*/
  1844. X    Sample(  4, (int)(x + (Tile_Width + 1)*3), y );/*Draw_Winter*/
  1845. X
  1846. X    y += (int)Tile_Height + 1;
  1847. X    Draw_Text( "Dragon", Board_Tile0_X, y );
  1848. X    Draw_Text( "Dragon", Board_Tile0_X+1, y );
  1849. X    Sample( 10, (int)(x + (Tile_Width + 1)*1), y );/*Draw_RDragon*/
  1850. X    Sample( 11, (int)(x + (Tile_Width + 1)*2), y );/*Draw_WDragon*/
  1851. X    Sample(  9, (int)(x + (Tile_Width + 1)*0), y );/*Draw_GDragon*/
  1852. X
  1853. X    y += (int)Tile_Height + 1;
  1854. X    Draw_Text( "Wind", Board_Tile0_X, y );
  1855. X    Draw_Text( "Wind", Board_Tile0_X+1, y );
  1856. X    Sample( 12, (int)(x + (Tile_Width + 1)*0), y );/*Draw_East*/
  1857. X    Sample( 13, (int)(x + (Tile_Width + 1)*1), y );/*Draw_West*/
  1858. X    Sample( 14, (int)(x + (Tile_Width + 1)*2), y );/*Draw_North*/
  1859. X    Sample( 15, (int)(x + (Tile_Width + 1)*3), y );/*Draw_South*/
  1860. X
  1861. X    y += (int)Tile_Height + 1;
  1862. X    Draw_Text( "Bam", Board_Tile0_X, y );
  1863. X    Draw_Text( "Bam", Board_Tile0_X+1, y );
  1864. X    Sample( 16, (int)(x + (Tile_Width + 1)*0), y );/*Draw_Bam1*/
  1865. X    Sample( 17, (int)(x + (Tile_Width + 1)*1), y );/*Draw_Bam2*/
  1866. X    Sample( 18, (int)(x + (Tile_Width + 1)*2), y );/*Draw_Bam3*/
  1867. X    Sample( 19, (int)(x + (Tile_Width + 1)*3), y );/*Draw_Bam4*/
  1868. X    Sample( 20, (int)(x + (Tile_Width + 1)*4), y );/*Draw_Bam5*/
  1869. X    Sample( 21, (int)(x + (Tile_Width + 1)*5), y );/*Draw_Bam6*/
  1870. X    Sample( 22, (int)(x + (Tile_Width + 1)*6), y );/*Draw_Bam7*/
  1871. X    Sample( 23, (int)(x + (Tile_Width + 1)*7), y );/*Draw_Bam8*/
  1872. X    Sample( 24, (int)(x + (Tile_Width + 1)*8), y );/*Draw_Bam9*/
  1873. X
  1874. X    y += (int)Tile_Height + 1;
  1875. X    Draw_Text( "Dot", Board_Tile0_X, y );
  1876. X    Draw_Text( "Dot", Board_Tile0_X+1, y );
  1877. X    Sample( 25, (int)(x + (Tile_Width + 1)*0), y );/*Draw_Dot1*/
  1878. X    Sample( 26, (int)(x + (Tile_Width + 1)*1), y );/*Draw_Dot2*/
  1879. X    Sample( 27, (int)(x + (Tile_Width + 1)*2), y );/*Draw_Dot3*/
  1880. X    Sample( 28, (int)(x + (Tile_Width + 1)*3), y );/*Draw_Dot4*/
  1881. X    Sample( 29, (int)(x + (Tile_Width + 1)*4), y );/*Draw_Dot5*/
  1882. X    Sample( 30, (int)(x + (Tile_Width + 1)*5), y );/*Draw_Dot6*/
  1883. X    Sample( 31, (int)(x + (Tile_Width + 1)*6), y );/*Draw_Dot7*/
  1884. X    Sample( 32, (int)(x + (Tile_Width + 1)*7), y );/*Draw_Dot8*/
  1885. X    Sample( 33, (int)(x + (Tile_Width + 1)*8), y );/*Draw_Dot9*/
  1886. X
  1887. X    y += (int)Tile_Height + 1;
  1888. X    Draw_Text( "Crak", Board_Tile0_X, y );
  1889. X    Draw_Text( "Crak", Board_Tile0_X+1, y );
  1890. X    Sample( 34, (int)(x + (Tile_Width + 1)*0), y );/*Draw_Crak1*/
  1891. X    Sample( 35, (int)(x + (Tile_Width + 1)*1), y );/*Draw_Crak2*/
  1892. X    Sample( 36, (int)(x + (Tile_Width + 1)*2), y );/*Draw_Crak3*/
  1893. X    Sample( 37, (int)(x + (Tile_Width + 1)*3), y );/*Draw_Crak4*/
  1894. X    Sample( 38, (int)(x + (Tile_Width + 1)*4), y );/*Draw_Crak5*/
  1895. X    Sample( 39, (int)(x + (Tile_Width + 1)*5), y );/*Draw_Crak6*/
  1896. X    Sample( 40, (int)(x + (Tile_Width + 1)*6), y );/*Draw_Crak7*/
  1897. X    Sample( 41, (int)(x + (Tile_Width + 1)*7), y );/*Draw_Crak8*/
  1898. X    Sample( 42, (int)(x + (Tile_Width + 1)*8), y );/*Draw_Crak9*/
  1899. X
  1900. X    XFlush( XtDisplay(Board) );
  1901. X    DEBUG_RETURN(Tile_Samples);
  1902. X
  1903. X} /* Tile_Samples */
  1904. X
  1905. X
  1906. X/*ARGSUSED*/
  1907. Xvoid Show_Samples( w, event, params, num_params )
  1908. X     Widget    w;
  1909. X     XEvent    *event;
  1910. X     String    *params;
  1911. X     Cardinal    *num_params;
  1912. X/******************************************************************************
  1913. X* Called when the Samples button is presses.  Display or un-display the sample
  1914. X* tiles.
  1915. X******************************************************************************/
  1916. X{
  1917. X
  1918. X    XClearArea( XtDisplay(Board), XtWindow(w),
  1919. X            0, Board_Tile0_Y - Side_Y - Shadow_Y, 0, 0, FALSE );
  1920. X    if (Board_State == s_Normal) {
  1921. X    Board_State = s_Sample;
  1922. X    Tile_Samples();
  1923. X    } else {
  1924. X    Board_State = s_Normal;
  1925. X    Board_Expose( w, event, params, num_params );
  1926. X    }
  1927. X
  1928. X} /* Show_Samples */
  1929. X
  1930. X
  1931. X/*ARGSUSED*/
  1932. Xstatic void Board_Expose( w, event, params, num_params )
  1933. X     Widget    w;
  1934. X     XEvent    *event;
  1935. X     String    *params;
  1936. X     Cardinal    *num_params;
  1937. X/******************************************************************************
  1938. X* Called when the Board receives an Expose event.
  1939. X******************************************************************************/
  1940. X{
  1941. X    int        i,j;
  1942. X    XEvent    event2;
  1943. X
  1944. X/*--Getting multiple events; at least when we start. */
  1945. X
  1946. X    DEBUG_CALL(Board_Expose);
  1947. X    while (XCheckWindowEvent( XtDisplay(Board), XtWindow(Board),
  1948. X                  ExposureMask, &event2 )) { }
  1949. X
  1950. X/*--Draw the correct stuff.  We might not want the current game. */
  1951. X
  1952. X    if (Board_State == s_Sample) {
  1953. X    Tile_Samples();
  1954. X    return;
  1955. X    }
  1956. X
  1957. X/*--Draw the entire board. */
  1958. X
  1959. X    for (i = 0; i < NROWS; ++i) {
  1960. X    for (j = 0; j < NCOLS; ++j) {
  1961. X        if (Board_Tiles[i][j].level > 0) {
  1962. X        Board_Tiles[i][j].draw = TRUE;
  1963. X        }
  1964. X    }
  1965. X    }
  1966. X    Draw_All_Tiles();
  1967. X
  1968. X/*--Make sure that it all goes out to the server. */
  1969. X
  1970. X    XFlush( XtDisplay(Board) );
  1971. X    DEBUG_RETURN(Board_Expose);
  1972. X
  1973. X} /* Board_Expose */
  1974. X
  1975. X
  1976. X/*ARGSUSED*/
  1977. Xstatic void Board_Configure( w, event, params, num_params )
  1978. X     Widget        w;
  1979. X     XConfigureEvent    *event;
  1980. X     String        *params;
  1981. X     Cardinal        *num_params;
  1982. X/******************************************************************************
  1983. X* Called when the Board receives a ConfigureNotify event.
  1984. X******************************************************************************/
  1985. X{
  1986. X    extern void Configure_Tiles();
  1987. X    int        old_height = Tile_Height;
  1988. X
  1989. X/*--Calculate the new Board size. */
  1990. X
  1991. X    DEBUG_CALL(Board_Configure);
  1992. X    Board_Width   = event->width;
  1993. X    Board_Height  = event->height;
  1994. X    Tile_Width    = (Board_Width-9) / 15 - 1;
  1995. X    Tile_Height   = (Board_Height-9) / 10 - 1;
  1996. X
  1997. X/*--Pick a tile size based upon the size of the board. */
  1998. X
  1999. X    if        (Tile_Width >= 80 && Tile_Height >= 96) {
  2000. X    Tile_Width  = 80;
  2001. X    Tile_Height = 96;
  2002. X    Configure_Tiles( 5 );
  2003. X    } else if (Tile_Width >= 68 && Tile_Height >= 80) {
  2004. X    Tile_Width  = 68;
  2005. X    Tile_Height = 80;
  2006. X    Configure_Tiles( 4 );
  2007. X    } else if (Tile_Width >= 56 && Tile_Height >= 64) {
  2008. X    Tile_Width  = 56;
  2009. X    Tile_Height = 64;
  2010. X    Configure_Tiles( 3 );
  2011. X    } else if (Tile_Width >= 40 && Tile_Height >= 48) {
  2012. X    Tile_Width  = 40;
  2013. X    Tile_Height = 48;
  2014. X    Configure_Tiles( 2 );
  2015. X    } else {
  2016. X    Tile_Width  = 28;
  2017. X    Tile_Height = 32;
  2018. X    Configure_Tiles( 1 );
  2019. X    }
  2020. X
  2021. X/*--Figure the real 0,0 coordinate. */
  2022. X
  2023. X    Board_Tile0_X = 4;
  2024. X    Board_Tile0_Y = 4 + 2 * Tile_Height;
  2025. X
  2026. X/*--Figure the Shadow and Side sizes. */
  2027. X
  2028. X    Shadow_X = Tile_Width  / 10;
  2029. X    Shadow_Y = Tile_Height / 10;
  2030. X    Side_X   = (Tile_Width  / 10) & ~1;
  2031. X    Side_Y   = (Tile_Height / 10) & ~1;
  2032. X
  2033. X/*--See if we need to repaint. */
  2034. X
  2035. X    if (old_height != Tile_Height) {
  2036. X    Do_Button_Configuration();
  2037. X    Set_Tile_Controls();
  2038. X    XClearArea( XtDisplay(Board), XtWindow(Board), 0, 0, 0, 0, TRUE );
  2039. X    }
  2040. X    DEBUG_RETURN(Board_Configure);
  2041. X
  2042. X} /* Board_Configure */
  2043. X
  2044. X
  2045. Xvoid Board_Setup()
  2046. X/******************************************************************************
  2047. X* Called to set up and create the Board widget.
  2048. X******************************************************************************/
  2049. X{
  2050. X#undef SETARG
  2051. X#define SETARG(name,value) \
  2052. X    DEBUG_ERROR(argi >= XtNumber(args), "BS args overrun!\n" ); \
  2053. X    XtSetArg( args[argi], name,  (XtArgVal)value ); ++argi;
  2054. X#undef ACTION
  2055. X#define ACTION(Name,Proc) \
  2056. X    DEBUG_ERROR(roui >= XtNumber(Routines), "BS Routines overrun!\n" ); \
  2057. X    Routines[roui].string = Name; \
  2058. X    Routines[roui].proc   = (XtActionProc)Proc; \
  2059. X    ++roui
  2060. X
  2061. X    static char    actions[] = "<Expose>:    ButtonExpose() BoardExpose()\n\
  2062. X                 <Configure>: BoardConfigure()\n\
  2063. X                 <Btn1Down>:  ButtonPress() TilePress()\n\
  2064. X                 <Btn1Up>:    ButtonRelease() TileRelease()\n\
  2065. X                 <Btn2Down>:  TileHints()\n\
  2066. X                 <Btn3Down>:  TileRemove()\n";
  2067. X    XtActionsRec    Routines[20];
  2068. X    int            roui = 0;
  2069. X    Arg            args[40];
  2070. X    int            argi = 0;
  2071. X
  2072. X/*--Define the various routines that we will be calling for various events
  2073. X *  on the Board. */
  2074. X
  2075. X    DEBUG_CALL(Board_Setup);
  2076. X    ACTION( "BoardConfigure",    Board_Configure );
  2077. X    ACTION( "BoardExpose",    Board_Expose );
  2078. X
  2079. X    ACTION( "ButtonExpose",    Button_Expose );
  2080. X    ACTION( "ButtonPress",    Button_Press );
  2081. X    ACTION( "ButtonRelease",    Button_Release );
  2082. X
  2083. X    ACTION( "TileHints",    Hints );
  2084. X    ACTION( "TileRemove",    Tile_Remove );
  2085. X    ACTION( "TilePress",    Tile_Press );
  2086. X    ACTION( "TileRelease",    Tile_Release );
  2087. X    XtAddActions( Routines, (Cardinal)roui );
  2088. X
  2089. X/*--Set up the various arguments to our Board. */
  2090. X
  2091. X    SETARG( XtNcursor,        Dragon_Resources.Cursor );
  2092. X    SETARG( XtNtranslations,    XtParseTranslationTable( actions ) );
  2093. X
  2094. X/*--Now actually create the board. */
  2095. X
  2096. X    Board = XtCreateManagedWidget( "board", simpleWidgetClass, Dragon,
  2097. X                   args, (Cardinal)argi );
  2098. X    XtRealizeWidget( Dragon );
  2099. X
  2100. X/*--Give the tiles a default initial size. */
  2101. X
  2102. X    {    XConfigureEvent        event;
  2103. X    event.width  = Board->core.width;
  2104. X    event.height = Board->core.height;
  2105. X    Board_Configure( (Widget)Board, &event,
  2106. X             (String*)NULL, (Cardinal*)NULL );
  2107. X    }
  2108. X
  2109. X/*--Give the buttons a default initial size based upon the Tile sizes. */
  2110. X
  2111. X    Do_Button_Configuration();
  2112. X
  2113. X/*--Set up the random number generator. */
  2114. X
  2115. X    {    extern char *initstate();
  2116. X    static char    data[32];
  2117. X    (void)initstate( (unsigned)time((long*)0), &data[0], sizeof(data) );
  2118. X#if 0
  2119. X    (void)initstate( 123456, &data[0], sizeof(data) );
  2120. X#endif
  2121. X    }
  2122. X
  2123. X/*--Set up the initial game. */
  2124. X
  2125. X    Setup_New_Game();
  2126. X
  2127. X    DEBUG_RETURN(Board_Setup);
  2128. X
  2129. X} /* Board_Setup */
  2130. END_OF_FILE
  2131. if test 30627 -ne `wc -c <'draw.c'`; then
  2132.     echo shar: \"'draw.c'\" unpacked with wrong size!
  2133. fi
  2134. # end of 'draw.c'
  2135. fi
  2136. if test -f 'Makefile.Canned' -a "${1}" != "-c" ; then 
  2137.   echo shar: Will not clobber existing file \"'Makefile.Canned'\"
  2138. else
  2139. echo shar: Extracting \"'Makefile.Canned'\" \(7665 characters\)
  2140. sed "s/^X//" >'Makefile.Canned' <<'END_OF_FILE'
  2141. X# Makefile generated by imake - do not edit!
  2142. X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
  2143. X#
  2144. X# The cpp used on this machine replaces all newlines and multiple tabs and
  2145. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  2146. X# for this, but is not always successful.
  2147. X#
  2148. X
  2149. X###########################################################################
  2150. X# X Window System Makefile generated from template file Imake.tmpl
  2151. X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
  2152. X#
  2153. X# Do not change the body of the imake template file.  Server-specific
  2154. X# parameters may be set in the appropriate .macros file; site-specific
  2155. X# parameters (but shared by all servers) may be set in site.def.  If you
  2156. X# make any changes, you'll need to rebuild the makefiles using
  2157. X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
  2158. X# the top level directory.
  2159. X#
  2160. X# If your C preprocessor doesn't define any unique symbols, you'll need
  2161. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  2162. X# "make Makefile", "make Makefiles", or "make World").
  2163. X#
  2164. X# If you absolutely can't get imake to work, you'll need to set the
  2165. X# variables at the top of each Makefile as well as the dependencies at the
  2166. X# bottom (makedepend will do this automatically).
  2167. X#
  2168. X
  2169. X###########################################################################
  2170. X# platform-specific configuration parameters - edit Sun.macros to change
  2171. X
  2172. X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
  2173. X# operating system:   SunOS 3.5
  2174. X
  2175. XBOOTSTRAPCFLAGS =
  2176. X             AS = as
  2177. X             CC = cc
  2178. X            CPP = /lib/cpp
  2179. X             LD = ld
  2180. X           LINT = lint
  2181. X        INSTALL = install
  2182. X           TAGS = ctags
  2183. X             RM = rm -f
  2184. X             MV = mv
  2185. X             LN = ln -s
  2186. X         RANLIB = ranlib
  2187. XRANLIBINSTFLAGS = -t
  2188. X             AR = ar clq
  2189. X             LS = ls
  2190. X       LINTOPTS = -axz
  2191. X    LINTLIBFLAG = -C
  2192. X           MAKE = make
  2193. XSTD_CPP_DEFINES =
  2194. X    STD_DEFINES =
  2195. X
  2196. X###########################################################################
  2197. X# site-specific configuration parameters - edit site.def to change
  2198. X
  2199. X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
  2200. X
  2201. X###########################################################################
  2202. X# definitions common to all Makefiles - do not edit
  2203. X
  2204. X          SHELL =  /bin/sh
  2205. X
  2206. X        DESTDIR =
  2207. X      USRLIBDIR = $(DESTDIR)/usr/lib
  2208. X         BINDIR = $(DESTDIR)/usr/local/bin/X11
  2209. X         INCDIR = $(DESTDIR)/usr/include/X11
  2210. X         ADMDIR = $(DESTDIR)/usr/adm
  2211. X         LIBDIR = $(USRLIBDIR)/X11
  2212. X     LINTLIBDIR = $(USRLIBDIR)/lint
  2213. X        FONTDIR = $(LIBDIR)/fonts
  2214. X       XINITDIR = $(LIBDIR)/xinit
  2215. X         XDMDIR = $(LIBDIR)/xdm
  2216. X         UWMDIR = $(LIBDIR)/uwm
  2217. X         AWMDIR = $(LIBDIR)/awm
  2218. X         TWMDIR = $(LIBDIR)/twm
  2219. X        MANPATH = $(DESTDIR)/usr/man
  2220. X  MANSOURCEPATH = $(MANPATH)/man
  2221. X         MANDIR = $(MANSOURCEPATH)n
  2222. X      LIBMANDIR = $(MANSOURCEPATH)3
  2223. X    XAPPLOADDIR = $(LIBDIR)/app-defaults
  2224. X
  2225. X   INSTBINFLAGS = -m 0755
  2226. X   INSTUIDFLAGS = -m 4755
  2227. X   INSTLIBFLAGS = -m 0664
  2228. X   INSTINCFLAGS = -m 0444
  2229. X   INSTMANFLAGS = -m 0444
  2230. X   INSTAPPFLAGS = -m 0444
  2231. X  INSTKMEMFLAGS = -m 4755
  2232. X        FCFLAGS = -t
  2233. X    CDEBUGFLAGS = -O
  2234. X
  2235. X        PATHSEP = /
  2236. X         DEPEND = $(DEPENDSRC)/makedepend
  2237. X          IMAKE = $(IMAKESRC)/imake
  2238. X            RGB = $(RGBSRC)/rgb
  2239. X             FC = $(BDFTOSNFSRC)/bdftosnf
  2240. X      MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
  2241. X      MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
  2242. X
  2243. X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
  2244. X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
  2245. X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
  2246. X            TOP = /src/x
  2247. X      CLIENTSRC = $(TOP)/clients
  2248. X        DEMOSRC = $(TOP)/demos
  2249. X         LIBSRC = $(TOP)/lib
  2250. X        FONTSRC = $(TOP)/fonts
  2251. X     INCLUDESRC = $(TOP)/X11
  2252. X      SERVERSRC = $(TOP)/server
  2253. X        UTILSRC = $(TOP)/util
  2254. X     SCRIPTSSRC = $(UTILSRC)/scripts
  2255. X     EXAMPLESRC = $(TOP)/examples
  2256. X     CONTRIBSRC = $(TOP)/contrib
  2257. X         DOCSRC = $(TOP)/doc
  2258. X         RGBSRC = $(TOP)/rgb
  2259. X      DEPENDSRC = $(UTILSRC)/makedepend
  2260. X       IMAKESRC = $(UTILSRC)/imake
  2261. X       IRULESRC = $(UTILSRC)/imake.includes
  2262. X        XLIBSRC = $(LIBSRC)/X
  2263. X         XMUSRC = $(LIBSRC)/Xmu
  2264. X     TOOLKITSRC = $(LIBSRC)/Xt
  2265. X     AWIDGETSRC = $(LIBSRC)/Xaw
  2266. X     OLDXLIBSRC = $(LIBSRC)/oldX
  2267. X    BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  2268. X   MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  2269. X   EXTENSIONSRC = $(TOP)/extensions
  2270. X   EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a
  2271. X           XLIB = $(XLIBSRC)/libX11.a
  2272. X         XMULIB = $(XMUSRC)/libXmu.a
  2273. X        OLDXLIB = $(OLDXLIBSRC)/liboldX.a
  2274. X       XTOOLLIB = $(TOOLKITSRC)/libXt.a
  2275. X         XAWLIB = $(AWIDGETSRC)/libXaw.a
  2276. X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
  2277. X        LINTXMU = $(XMUSRC)/llib-lXmu.ln
  2278. X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
  2279. X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
  2280. X       INCLUDES = -I$(TOP)
  2281. X      MACROFILE = Sun.macros
  2282. X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
  2283. X            $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
  2284. X  IMAKE_DEFINES =
  2285. X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
  2286. X            -s Makefile $(IMAKE_DEFINES)
  2287. X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
  2288. X            .emacs_* tags TAGS make.log MakeOut
  2289. X
  2290. X###########################################################################
  2291. X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
  2292. X
  2293. X###########################################################################
  2294. X# start of Imakefile
  2295. X
  2296. X           SRCS = main.c board.c button.c draw.c icon.c tile.c tile_bits.c
  2297. X           OBJS = main.o board.o button.o draw.o icon.o tile.o tile_bits.o
  2298. X       PROGRAMS = dragon
  2299. X       LINTOPTS = -uxz
  2300. X        DEFINES = -DWANTDEBUG
  2301. X       INCLUDES =
  2302. X  SYS_LIBRARIES = -lXaw -lXmu -lXt -lX11
  2303. X
  2304. X PROGRAM = dragon
  2305. X
  2306. Xall:: dragon
  2307. X
  2308. Xdragon: $(OBJS) $(LOCAL_LIBRARIES)
  2309. X    $(RM) $@
  2310. X    $(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
  2311. X
  2312. Xrelink::
  2313. X    $(RM) $(PROGRAM)
  2314. X    $(MAKE) $(MFLAGS) $(PROGRAM)
  2315. X
  2316. Xinstall:: dragon
  2317. X    $(INSTALL) -c $(INSTALLFLAGS) dragon $(BINDIR)
  2318. X
  2319. Xinstall.man:: dragon.man
  2320. X    $(INSTALL) -c $(INSTMANFLAGS) dragon.man $(MANDIR)/dragon.n
  2321. X
  2322. Xdepend:: $(DEPEND)
  2323. X
  2324. Xdepend::
  2325. X    $(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
  2326. X
  2327. X$(DEPEND):
  2328. X    @echo "making $@"; \
  2329. X    cd $(DEPENDSRC); $(MAKE)
  2330. X
  2331. Xclean::
  2332. X    $(RM) $(PROGRAM)
  2333. X
  2334. Xdragon: $(USRLIBDIR)/libXaw.a \
  2335. X           $(USRLIBDIR)/libXmu.a \
  2336. X           $(USRLIBDIR)/libXt.a \
  2337. X           $(USRLIBDIR)/libX11.a
  2338. X
  2339. Xlint:
  2340. X    $(LINT) $(LINTFLAGS) $(SRCS)
  2341. X
  2342. XMakeBug:
  2343. X    cp Makefile MakeBug.bak
  2344. X    make -f MakeBug.bak Makefile
  2345. X    rm MakeBug.bak
  2346. X
  2347. Xtar:
  2348. X    tar cf - . > ../dragon.tar
  2349. X    compress -v ../dragon.tar
  2350. X
  2351. X###########################################################################
  2352. X# Imake.tmpl common rules for all Makefiles - do not edit
  2353. X
  2354. Xemptyrule::
  2355. X
  2356. Xclean::
  2357. X    $(RM_CMD) \#*
  2358. X
  2359. XMakefile:: $(IMAKE)
  2360. X
  2361. XMakefile:: Imakefile \
  2362. X    $(IRULESRC)/Imake.tmpl \
  2363. X    $(IRULESRC)/Imake.rules \
  2364. X    $(IRULESRC)/site.def \
  2365. X    $(IRULESRC)/$(MACROFILE)
  2366. X    -@if [ -f Makefile ]; then \
  2367. X    echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  2368. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  2369. X    else exit 0; fi
  2370. X    $(IMAKE_CMD) -DTOPDIR=$(TOP)
  2371. X
  2372. X$(IMAKE):
  2373. X    @echo "making $@"; \
  2374. X    cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
  2375. X
  2376. Xtags::
  2377. X    $(TAGS) -w *.[ch]
  2378. X    $(TAGS) -xw *.[ch] > TAGS
  2379. X
  2380. X###########################################################################
  2381. X# empty rules for directories that do not have SUBDIRS - do not edit
  2382. X
  2383. Xinstall::
  2384. X    @echo "install done"
  2385. X
  2386. Xinstall.man::
  2387. X    @echo "install.man done"
  2388. X
  2389. XMakefiles::
  2390. X
  2391. X###########################################################################
  2392. X# dependencies generated by makedepend
  2393. X
  2394. END_OF_FILE
  2395. if test 7665 -ne `wc -c <'Makefile.Canned'`; then
  2396.     echo shar: \"'Makefile.Canned'\" unpacked with wrong size!
  2397. fi
  2398. # end of 'Makefile.Canned'
  2399. fi
  2400. echo shar: End of shell archive.
  2401. exit 0
  2402.